diff -Nru avidemux2.6-2.6.7~ppa3/addons/avsfilter/avsload.cpp avidemux2.6-2.6.8~ppa1/addons/avsfilter/avsload.cpp --- avidemux2.6-2.6.7~ppa3/addons/avsfilter/avsload.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/addons/avsfilter/avsload.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -61,6 +61,8 @@ #define BUF_SIZE (1920L * 1080L * 3L >> 1L) //#define BUF_SIZE 65536 +bool fget_pitch_data = false; + void test_pipe_speed(int h_read, int h_write, char *copy_buf, int buf_sz, int time_sec) { @@ -140,7 +142,7 @@ *avsdll = LoadLibrary("avisynth.dll"); if(!*avsdll) { - DEBUG_PRINTF("avsloader : failed to load avisynth.dll\n"); + DEBUG_PRINTF_RED("avsloader : failed to load avisynth.dll\n"); fflush(stdout); return false; } @@ -149,7 +151,7 @@ = (IScriptEnvironment*(*)(int)) GetProcAddress(*avsdll, "CreateScriptEnvironment"); if(!CreateScriptEnvironment) { - DEBUG_PRINTF("avsloader : failed to load CreateScriptEnvironment()\n"); + DEBUG_PRINTF_RED("avsloader : failed to load CreateScriptEnvironment()\n"); fflush(stdout); free_lib: @@ -161,7 +163,7 @@ } catch(AvisynthError err) { - DEBUG_PRINTF("avsloader : avisynth error %s\n", err.msg); + DEBUG_PRINTF_RED("avsloader : avisynth error %s\n", err.msg); return false; } return true; @@ -176,7 +178,7 @@ if(!res.IsClip()) { - DEBUG_PRINTF("avsloader : '%s' didn't return a video clip.\n", infile); + DEBUG_PRINTF_RED("avsloader : '%s' didn't return a video clip.\n", infile); fflush(stdout); return false; } @@ -185,7 +187,7 @@ } catch(AvisynthError err) { - DEBUG_PRINTF("avsloader : avisynth error %s\n", err.msg); + DEBUG_PRINTF_RED("avsloader : avisynth error %s\n", err.msg); return false; } return true; @@ -202,7 +204,7 @@ if(!pipe_dll) { - DEBUG_PRINTF("failed to load %s\n", dllname); + DEBUG_PRINTF_RED("failed to load %s\n", dllname); fflush(stdout); return false; } @@ -211,7 +213,7 @@ "SetPipeName"); if(!set_pipe_name) { - DEBUG_PRINTF("failed to get SetPipeName\n"); + DEBUG_PRINTF_RED("failed to get SetPipeName\n"); fflush(stdout); free_lib: @@ -230,29 +232,6 @@ #define PIPE_LOADER_WRITE 0 #define PIPE_FILTER_READ 2 -/* - void BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) { - if ( (!height)|| (!row_size)) return; - if (GetCPUFlags() & CPUF_INTEGER_SSE) { - if (height == 1 || (src_pitch == dst_pitch && dst_pitch == row_size)) { - memcpy_amd(dstp, srcp, row_size*height); - } else { - asm_BitBlt_ISSE(dstp,dst_pitch,srcp,src_pitch,row_size,height); - } - return; - } - if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) { - memcpy(dstp, srcp, row_size*height); - } else { - for (int y=height; y>0; --y) { - memcpy(dstp, srcp, row_size); - dstp += dst_pitch; - srcp += src_pitch; - } - } - - */ - bool send_bit_blt(int h, const BYTE* srcp, int src_pitch, int row_size, int height, BYTE *data) @@ -286,7 +265,7 @@ if (!load_avisynth(&env, &avsdll)) { - DEBUG_PRINTF("avsloader : cannot load avisynth dll\n"); + DEBUG_PRINTF_RED("avsloader : cannot load avisynth dll\n"); fflush(stdout); return; } @@ -320,7 +299,11 @@ switch(msg.avs_cmd) { - case LOAD_AVS_SCRIPT: + case GET_PITCH_DATA: + fget_pitch_data = true; + break; + + case LOAD_AVS_SCRIPT: DEBUG_PRINTF("avsloader : try load avisynth.dll and script %s\n", data); @@ -345,12 +328,13 @@ info.nb_frames = inf.num_frames; info.fps1000 = inf.fps_numerator * 1000 / inf.fps_denominator; info.orgFrame = 0; + info.encoding = MAGIC_ADV_PROTOCOL_VAL; // set advanced protocol from avsfilter to avsloader if (!send_cmd(avs_pipes[PIPE_LOADER_WRITE].hpipe, SET_CLIP_PARAMETER, (void*)&info, sizeof(ADV_Info))) { - DEBUG_PRINTF("avsloader : cannot send avisynth clip param to avsfilter\n"); + DEBUG_PRINTF_RED("avsloader : cannot send avisynth clip param to avsfilter\n"); fflush(stdout); return; } @@ -366,7 +350,7 @@ DEBUG_PRINTF("avsloader : UNLOAD_AVS_LOADER ok\n"); terminate = true; break; - + case GET_FRAME_WITH_PITCH: case GET_FRAME: // avidemux2 avsfilter tell : get frame fd = (FRAME_DATA *)data; @@ -386,37 +370,39 @@ fflush(stdout); fd_copy = *fd; - /* - void BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) { - if ( (!height)|| (!row_size)) return; - if (GetCPUFlags() & CPUF_INTEGER_SSE) { - if (height == 1 || (src_pitch == dst_pitch && dst_pitch == row_size)) { - memcpy_amd(dstp, srcp, row_size*height); - } else { - asm_BitBlt_ISSE(dstp,dst_pitch,srcp,src_pitch,row_size,height); - } - return; - } - if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) { - memcpy(dstp, srcp, row_size*height); - } else { - for (int y=height; y>0; --y) { - memcpy(dstp, srcp, row_size); - dstp += dst_pitch; - srcp += src_pitch; - } - } - */ -#ifdef PREVENT_INTERMEDIATE_BUFFERS - if (!send_cmd_with_specified_size(avs_pipes[PIPE_LOADER_WRITE].hpipe, - PUT_FRAME, - (void*)&fd_copy, sizeof(FRAME_DATA), - frame_sz)) + + if (msg.avs_cmd == GET_FRAME_WITH_PITCH) { - DEBUG_PRINTF("avsloader : error send frame header to avsfilter\n"); + uint32_t pitch_data_sizeY = f->GetPitch(PLANAR_Y) * f->GetHeight(PLANAR_Y); + uint32_t pitch_data_sizeU = f->GetPitch(PLANAR_U) * f->GetHeight(PLANAR_U); + uint32_t pitch_data_sizeV = f->GetPitch(PLANAR_V) * f->GetHeight(PLANAR_V); + uint32_t pitch_data_size = pitch_data_sizeY + pitch_data_sizeU + pitch_data_sizeV; + DEBUG_PRINTF("avsloader : pitch frame size %lu\n", pitch_data_size); + + if (!send_cmd_with_specified_size(avs_pipes[PIPE_LOADER_WRITE].hpipe, + PUT_FRAME_WITH_PITCH, + (void*)&fd_copy, sizeof(FRAME_DATA), pitch_data_size) || + ppwrite(avs_pipes[PIPE_LOADER_WRITE].hpipe, (void*)f->GetReadPtr(PLANAR_Y), pitch_data_sizeY) != pitch_data_sizeY || + ppwrite(avs_pipes[PIPE_LOADER_WRITE].hpipe, (void*)f->GetReadPtr(PLANAR_U), pitch_data_sizeU) != pitch_data_sizeU || + ppwrite(avs_pipes[PIPE_LOADER_WRITE].hpipe, (void*)f->GetReadPtr(PLANAR_V), pitch_data_sizeV) != pitch_data_sizeV) + { + DEBUG_PRINTF_RED("avsloader : error send uncompressed PITCH frame to avsfilter\n"); fflush(stdout); + return; + } } else + { +#ifdef PREVENT_INTERMEDIATE_BUFFERS + if (!send_cmd_with_specified_size(avs_pipes[PIPE_LOADER_WRITE].hpipe, + PUT_FRAME, + (void*)&fd_copy, sizeof(FRAME_DATA), + frame_sz)) + { + DEBUG_PRINTF_RED("avsloader : error send frame header to avsfilter\n"); + fflush(stdout); + } + else if (!send_bit_blt(avs_pipes[PIPE_LOADER_WRITE].hpipe, f->GetReadPtr(), f->GetPitch(), inf.width, inf.height, data) || @@ -427,31 +413,46 @@ f->GetReadPtr(PLANAR_U), f->GetPitch(PLANAR_U), inf.width / 2, inf.height / 2, data)) { - DEBUG_PRINTF("avsloader : error send frame data to avsfilter\n"); - fflush(stdout); + DEBUG_PRINTF_RED("avsloader : error send frame data to avsfilter\n"); + fflush(stdout); } #else - // copy Y, U and V with pitch - env->BitBlt(data, inf.width, f->GetReadPtr(), f->GetPitch(), inf.width, inf.height); - env->BitBlt(data + (inf.width * inf.height), inf.width / 2, - f->GetReadPtr(PLANAR_V), f->GetPitch(PLANAR_V), - inf.width / 2, inf.height / 2); - env->BitBlt(data + (inf.width * inf.height) + ((inf.width * inf.height) >> 2), - inf.width / 2, f->GetReadPtr(PLANAR_U), f->GetPitch(PLANAR_U), - inf.width / 2, inf.height / 2); - - // return filtered data - if (!send_cmd_by_two_part(avs_pipes[PIPE_LOADER_WRITE].hpipe, - PUT_FRAME, - (void*)&fd_copy, sizeof(FRAME_DATA), - (void*)data, frame_sz)) - { - DEBUG_PRINTF("avsloader : error send frame to avsfilter\n"); + // copy Y, U and V with pitch + env->BitBlt(data, inf.width, f->GetReadPtr(), f->GetPitch(), inf.width, inf.height); + env->BitBlt(data + (inf.width * inf.height), inf.width / 2, + f->GetReadPtr(PLANAR_V), f->GetPitch(PLANAR_V), + inf.width / 2, inf.height / 2); + env->BitBlt(data + (inf.width * inf.height) + ((inf.width * inf.height) >> 2), + inf.width / 2, f->GetReadPtr(PLANAR_U), f->GetPitch(PLANAR_U), + inf.width / 2, inf.height / 2); + + // return filtered data + if (!send_cmd_by_two_part(avs_pipes[PIPE_LOADER_WRITE].hpipe, + PUT_FRAME, + (void*)&fd_copy, sizeof(FRAME_DATA), + (void*)data, frame_sz)) + { + DEBUG_PRINTF_RED("avsloader : error send frame to avsfilter\n"); fflush(stdout); return; - } + } + + if (fget_pitch_data) + { + PITCH_DATA pd = {f->GetPitch(PLANAR_Y), f->GetPitch(PLANAR_U), f->GetPitch(PLANAR_V)}; + // send SEND_PITCH_DATA_AVSLOADER to avidemux2/avsfilter + if (!send_cmd(avs_pipes[PIPE_LOADER_WRITE].hpipe, + SEND_PITCH_DATA_AVSLOADER, + (void*)&pd, sizeof(pd))) + DEBUG_PRINTF_RED("avsloader : error send SEND_PITCH_DATA_AVSLOADER to avsfilter\n"); + else + DEBUG_PRINTF("avsloader : send SEND_PITCH_DATA_AVSLOADER ok\n"); + fflush(stdout); + fget_pitch_data = false; + } #endif + } break; } @@ -503,7 +504,7 @@ open(avs_pipes[i].pipename, avs_pipes[i].flags)) == -1 && j--) { - DEBUG_PRINTF("error open %s, try %d, errno %d\n", + DEBUG_PRINTF_RED("error open %s, try %d, errno %d\n", avs_pipes[i].pipename, j_old - j, errno); Sleep(WAIT_BEFORE_TRY); } @@ -521,7 +522,7 @@ avs_pipes[PIPE_LOADER_WRITE].hpipe, &cb_send_data, pipe_timeout)) { - DEBUG_PRINTF("avsload : cannot call SetPipeHandle\n"); + DEBUG_PRINTF_RED("avsload : cannot call SetPipeHandle\n"); goto cleanup_close_pipes; } @@ -529,10 +530,10 @@ if (!pipe_test (avs_pipes[PIPE_LOADER_READ].hpipe, avs_pipes[PIPE_LOADER_WRITE].hpipe)) { - DEBUG_PRINTF("avsload : cannot test pipe from loader to avsfilter\n"); + DEBUG_PRINTF_RED("avsload : cannot test pipe from loader to avsfilter\n"); goto cleanup_close_pipes; - } + DEBUG_PRINTF("avsload : test pipe from loader to avsfilter ok\n"); fflush(stdout); Binary files /tmp/kSZ6UDel6E/avidemux2.6-2.6.7~ppa3/addons/avsfilter/avsload_pipe_binary.tar.bz2 and /tmp/Kdso2N10qw/avidemux2.6-2.6.8~ppa1/addons/avsfilter/avsload_pipe_binary.tar.bz2 differ diff -Nru avidemux2.6-2.6.7~ppa3/addons/avsfilter/avspipecomm.h avidemux2.6-2.6.8~ppa1/addons/avsfilter/avspipecomm.h --- avidemux2.6-2.6.7~ppa3/addons/avsfilter/avspipecomm.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/addons/avsfilter/avspipecomm.h 2014-03-12 06:15:23.000000000 +0000 @@ -37,7 +37,12 @@ GET_FRAME, PUT_FRAME, //4 UNLOAD_AVS_SCRIPT, - UNLOAD_AVS_LOADER + UNLOAD_AVS_LOADER, + SEND_PITCH_DATA_PIPE_SOURCE, + SEND_PITCH_DATA_AVSLOADER, + GET_PITCH_DATA, + GET_FRAME_WITH_PITCH, + PUT_FRAME_WITH_PITCH } AVS_CMD; typedef struct @@ -52,12 +57,18 @@ PUT_FRAME - frame and frame_data[] set to corresponding value */ typedef struct - { uint32_t frame; unsigned char frame_data[0]; } FRAME_DATA; +typedef struct +{ + uint32_t pitchY; + uint32_t pitchU; + uint32_t pitchV; +}PITCH_DATA; + bool send_cmd(int hw, AVS_CMD cmd, void *data, int sz); @@ -79,3 +90,4 @@ int ppwrite(int h, void *data, int sz); #define PIPE_MAX_TRANSFER_SZ 65536/2 +#define MAGIC_ADV_PROTOCOL_VAL 0xADBACEED diff -Nru avidemux2.6-2.6.7~ppa3/addons/avsfilter/cdebug.cpp avidemux2.6-2.6.8~ppa1/addons/avsfilter/cdebug.cpp --- avidemux2.6-2.6.7~ppa3/addons/avsfilter/cdebug.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/addons/avsfilter/cdebug.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -21,6 +21,10 @@ #include #include FILE *dbglog = stdout; + +#define RED_TEXT "\033[31m" +#define END_TEXT "\033[0m" + extern "C" void setdbglog (const char *fname) { FILE *out; @@ -28,16 +32,32 @@ dbglog = out; } -extern "C" void dbgprintf (const char *format, ...) +extern "C" void dbgprintf_p (const char *format, va_list args) { time_t t = time(NULL); struct tm *tmp = localtime(&t); - va_list args; - va_start (args, format); if (strcmp(format,"\n")) - fprintf (dbglog,"%02d:%02d:%02d ", tmp->tm_hour, tmp->tm_min, tmp->tm_sec); - vfprintf (dbglog, format, args); + fprintf (dbglog,"%02d:%02d:%02d ", tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + if (dbglog == stdout) vprintf (format, args); + else vfprintf (dbglog, format, args); fflush(dbglog); +} + +extern "C" void dbgprintf (const char *format, ...) +{ + va_list args; + va_start (args, format); + dbgprintf_p (format, args); + va_end (args); +} + +extern "C" void dbgprintf_RED (const char *format, ...) +{ + va_list args; + va_start (args, format); + if (dbglog == stdout) {printf(RED_TEXT); fflush(dbglog);} + dbgprintf_p (format, args); + if (dbglog == stdout) { printf(END_TEXT); fflush(dbglog);} va_end (args); } #endif diff -Nru avidemux2.6-2.6.7~ppa3/addons/avsfilter/cdebug.h avidemux2.6-2.6.8~ppa1/addons/avsfilter/cdebug.h --- avidemux2.6-2.6.7~ppa3/addons/avsfilter/cdebug.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/addons/avsfilter/cdebug.h 2014-03-12 06:15:23.000000000 +0000 @@ -19,9 +19,12 @@ #define __CDEBUG__ #ifdef DEBUGMSG extern "C" void dbgprintf (const char *format, ...); +extern "C" void dbgprintf_RED (const char *format, ...); extern "C" void setdbglog (const char *fname); #define DEBUG_PRINTF dbgprintf +#define DEBUG_PRINTF_RED dbgprintf_RED #else +#define DEBUG_PRINTF_RED #define DEBUG_PRINTF #endif diff -Nru avidemux2.6-2.6.7~ppa3/addons/avsfilter/pipe_source.cpp avidemux2.6-2.6.8~ppa1/addons/avsfilter/pipe_source.cpp --- avidemux2.6-2.6.7~ppa3/addons/avsfilter/pipe_source.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/addons/avsfilter/pipe_source.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -27,8 +27,11 @@ #include "cdebug.h" bool pipe_test(int hr, int hw); +//bool use_adv_protocol = false; +static int refCounter = 0; + int h_read = -1, h_write = -1; -uint32_t frame_sz = 0; +uint32_t frame_sz = 0, frame_sz_pitch = 0; unsigned char *frame_data = NULL; #define WAIT_BEFORE_TRY 500 @@ -65,11 +68,12 @@ } if (sz1 != sizeof(uint32_t)) { - DEBUG_PRINTF("pipe_source : cannot read test data - read %d\n", sz1); + DEBUG_PRINTF_RED("pipe_source : cannot read test data - read %d\n", sz1); fflush(stdout); close (h_read); return false; } + if (cb_send_data(hw, (unsigned char*)&test_r1, sz1)) { h_write = hw; @@ -78,7 +82,7 @@ } else { - DEBUG_PRINTF("pipe_source : cannot write test data\n"); + DEBUG_PRINTF_RED("pipe_source : cannot write test data\n"); close (h_read); } } @@ -105,6 +109,8 @@ PIPE_MSG_HEADER msg; ADV_Info ai; + refCounter++; + vi.width = 720; vi.height = 576; vi.fps_numerator = 25; @@ -134,68 +140,128 @@ vi.num_frames = ai.nb_frames + ai.orgFrame; vi.fps_numerator = ai.fps1000; vi.fps_denominator = 1000; + if (ai.encoding == MAGIC_ADV_PROTOCOL_VAL) + { + PVideoFrame dst; + PIPE_MSG_HEADER msg = {SEND_PITCH_DATA_PIPE_SOURCE, sizeof(PITCH_DATA)}; + dst = env->NewVideoFrame(vi); + + PITCH_DATA pd = {dst->GetPitch(PLANAR_Y), dst->GetPitch(PLANAR_U), dst->GetPitch(PLANAR_V)}; + // send SEND_PITCH_DATA to avidemux2/avsfilter + if (!pcb_send_data(h_write, (unsigned char*)&msg, sizeof(msg)) || + !pcb_send_data(h_write, (unsigned char*)&pd, sizeof(pd))) + DEBUG_PRINTF_RED("pipe_source : error send SEND_PITCH_DATA_PIPE_SOURCE to avsfilter\n"); + else + DEBUG_PRINTF("pipe_source : send SEND_PITCH_DATA_PIPE_SOURCE ok\n"); + + fflush(stdout); + + //use_adv_protocol = true; + frame_sz_pitch = dst->GetPitch(PLANAR_Y) * dst->GetHeight(PLANAR_Y) + dst->GetPitch(PLANAR_U) * dst->GetHeight(PLANAR_U) + dst->GetPitch(PLANAR_V) * dst->GetHeight(PLANAR_V); + DEBUG_PRINTF("pipe_source : use advanced protocol (%d)\n", frame_sz_pitch); + delete dst; + } frame_sz = (vi.width * vi.height * 3) >> 1; - frame_data = (unsigned char*)malloc(frame_sz); + frame_data = (unsigned char*)malloc(frame_sz_pitch > frame_sz ? frame_sz_pitch : frame_sz); } else - DEBUG_PRINTF("pipe_source : error receive_data with info\n"); + DEBUG_PRINTF_RED("pipe_source : error receive_data with info\n"); else - DEBUG_PRINTF("pipe_source : receive_data return wrong header\n"); + DEBUG_PRINTF_RED("pipe_source : receive_data return wrong header\n"); else - DEBUG_PRINTF("pipe_source : error receive_data with header\n"); + DEBUG_PRINTF_RED("pipe_source : error receive_data with header\n"); } PipeSource::~PipeSource() { DEBUG_PRINTF("Delete PipeSource\n"); fflush(stdout); + refCounter--; + if (!refCounter && frame_data) free(frame_data); } PVideoFrame __stdcall PipeSource::GetFrame(int n, IScriptEnvironment* env) { - PVideoFrame dst; - dst = env->NewVideoFrame(vi); + PVideoFrame dst; + dst = env->NewVideoFrame(vi); PIPE_MSG_HEADER msg = {GET_FRAME, sizeof(FRAME_DATA)}; FRAME_DATA fd = {n}; DEBUG_PRINTF("pipe_source : invoke GetFrame %d [num_frames %d]\n", n, vi.num_frames); - DEBUG_PRINTF("pipe_source : frame pitch %d\n", dst->GetPitch()); + DEBUG_PRINTF("pipe_source : frame pitch YUV %d %d %d\n", dst->GetPitch(PLANAR_Y), dst->GetPitch(PLANAR_U), dst->GetPitch(PLANAR_V)); fflush(stdout); // send GET_FRAME to avidemux2/avsfilter if (!pcb_send_data(h_write, (unsigned char*)&msg, sizeof(msg)) || !pcb_send_data(h_write, (unsigned char*)&fd, sizeof(fd))) { - DEBUG_PRINTF("pipe_source : error send GET_FRAME to avsfilter\n", n); + DEBUG_PRINTF_RED("pipe_source : error send GET_FRAME to avsfilter\n", n); fflush(stdout); return dst; } DEBUG_PRINTF("pipe_source : send GET_FRAME ok\n"); fflush(stdout); - + +#define CUR_FRAME_SIZE (msg.avs_cmd == PUT_FRAME ? frame_sz : frame_sz_pitch) + int test_sz = 0; // receive frame from avsfilter if (!receive_cmd(h_read, &msg) || - msg.avs_cmd != PUT_FRAME || + (msg.avs_cmd != PUT_FRAME && msg.avs_cmd != PUT_FRAME_WITH_PITCH) || ppread(h_read, &fd, sizeof(fd)) != sizeof(fd) || - fd.frame != n || (frame_sz + sizeof(fd)) != msg.sz || - (test_sz = ppread(h_read, frame_data, frame_sz)) != frame_sz) + fd.frame != n || (CUR_FRAME_SIZE + sizeof(fd)) != msg.sz) + { + DEBUG_PRINTF_RED("pipe_source : error get frame, par [code %d sz %d frame %d] chk par [frame_sz %d read_sz %d]\n", + msg.avs_cmd, msg.sz, fd.frame, frame_sz, test_sz); + fflush(stdout); + return dst; + } + + if (msg.avs_cmd == PUT_FRAME) { - DEBUG_PRINTF("pipe_source : error get frame, par [code %d sz %d frame %d] chk par [frame_sz %d read_sz %d]\n", - msg.avs_cmd, msg.sz, fd.frame, frame_sz, test_sz); + if ((test_sz = ppread(h_read, frame_data, CUR_FRAME_SIZE)) != CUR_FRAME_SIZE) + { + DEBUG_PRINTF_RED("pipe_source : error get frame data, par [frame %d] chk par [frame_sz %d read_sz %d]\n", + fd.frame, frame_sz, test_sz); fflush(stdout); return dst; + } + + // copy Y, U and V with pitch + env->BitBlt(dst->GetWritePtr(), dst->GetPitch(), frame_data, vi.width, vi.width, vi.height); + env->BitBlt(dst->GetWritePtr(PLANAR_V), dst->GetPitch(PLANAR_V), + frame_data + (vi.width * vi.height), vi.width / 2, vi.width / 2, vi.height / 2); + env->BitBlt(dst->GetWritePtr(PLANAR_U), dst->GetPitch(PLANAR_U), + frame_data + (vi.width * vi.height) + ((vi.width * vi.height) >> 2), + vi.width / 2, vi.width / 2, vi.height / 2); } + else + { + uint32_t pitch_data_sizeY = dst->GetPitch(PLANAR_Y) * dst->GetHeight(PLANAR_Y); + uint32_t pitch_data_sizeU = dst->GetPitch(PLANAR_U) * dst->GetHeight(PLANAR_U); + uint32_t pitch_data_sizeV = dst->GetPitch(PLANAR_V) * dst->GetHeight(PLANAR_V); + uint32_t pitch_data_size = pitch_data_sizeY + pitch_data_sizeU + pitch_data_sizeV; + +/* DEBUG_PRINTF("pipe_source : PUT_FRAME_WITH_PITCH (%d) Pitch:Height %d:%d\n", CUR_FRAME_SIZE, dst->GetPitch(PLANAR_Y), dst->GetHeight(PLANAR_Y));*/ + if (msg.sz != (pitch_data_size + sizeof(FRAME_DATA))) + { + DEBUG_PRINTF_RED("pipe_source : error size of PITCH frame data %d != %d + %d [msg.sz != (pitch_data_size + sizeof(FRAME_DATA))] \n", + msg.sz, pitch_data_size, sizeof(FRAME_DATA)); + fflush(stdout); + return dst; + } - // copy Y, U and V with pitch - env->BitBlt(dst->GetWritePtr(), dst->GetPitch(), frame_data, vi.width, vi.width, vi.height); - env->BitBlt(dst->GetWritePtr(PLANAR_V), dst->GetPitch(PLANAR_V), - frame_data + (vi.width * vi.height), vi.width / 2, vi.width / 2, vi.height / 2); - env->BitBlt(dst->GetWritePtr(PLANAR_U), dst->GetPitch(PLANAR_U), - frame_data + (vi.width * vi.height) + ((vi.width * vi.height) >> 2), - vi.width / 2, vi.width / 2, vi.height / 2); + if (ppread(h_read, dst->GetWritePtr(PLANAR_Y), pitch_data_sizeY) != pitch_data_sizeY || + ppread(h_read, dst->GetWritePtr(PLANAR_U), pitch_data_sizeU) != pitch_data_sizeU || + ppread(h_read, dst->GetWritePtr(PLANAR_V), pitch_data_sizeV) != pitch_data_sizeV) + { + DEBUG_PRINTF_RED("pipe_source : error get PITCH frame data %d %d %d\n", pitch_data_sizeY, pitch_data_sizeU, pitch_data_sizeV); + fflush(stdout); + return dst; + } + } DEBUG_PRINTF("pipe_source : return frame %d data ok\n", fd.frame); fflush(stdout); diff -Nru avidemux2.6-2.6.7~ppa3/autononreg/py/environ/env.py avidemux2.6-2.6.8~ppa1/autononreg/py/environ/env.py --- avidemux2.6-2.6.7~ppa3/autononreg/py/environ/env.py 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/autononreg/py/environ/env.py 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,13 @@ +# check get_folder_content function +# return the list of files with extention ext +# full path is returned ! +# i.e. in the example below you will get a list +# /work/samples/avi/foo.avi +# /work/samples/avi/bar.avi +# ... +# +import os +print("environ ") +val=os.environ("foo") +print("val:"+str(val)) +print("Done") diff -Nru avidemux2.6-2.6.7~ppa3/autononreg/py/helpers/pySub1.py avidemux2.6-2.6.8~ppa1/autononreg/py/helpers/pySub1.py --- avidemux2.6-2.6.7~ppa3/autononreg/py/helpers/pySub1.py 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/autononreg/py/helpers/pySub1.py 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1 @@ +testSub('/work/subs/fedor.srt') diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_audioFilter/src/audiocopy.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_audioFilter/src/audiocopy.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_audioFilter/src/audiocopy.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_audioFilter/src/audiocopy.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -372,7 +372,7 @@ { uint64_t currentClock=clock->getTimeUs(); aprintf("Duping clockDts=%d, syncDts=%d\n",currentClock,nextDts); - if( fabs((double)nextDts-(double)currentClocknextDts) ) + if( (fabs((double)nextDts-(double)currentClock)nextDts) ) { aprintf("Close enough..\n"); changeState(Flushing); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_audioFilter/src/audiofilter_mixer.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_audioFilter/src/audiofilter_mixer.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_audioFilter/src/audiofilter_mixer.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_audioFilter/src/audiofilter_mixer.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -573,6 +573,7 @@ uint32_t rd = 0; int nbSampleMax=max/_wavHeader.channels; + if(!nbSampleMax) nbSampleMax=1; uint8_t input_channels = _previous->getInfo()->channels; // Fill incoming buffer diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_audioFilter/src/audiofilter_normalize.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_audioFilter/src/audiofilter_normalize.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_audioFilter/src/audiofilter_normalize.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_audioFilter/src/audiofilter_normalize.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -32,7 +32,7 @@ #if defined (_WIN32) || defined (__HAIKU__) #define POW10(x) pow(10,x) -#elif defined(ADM_BSD_FAMILY) +#elif defined(ADM_BSD_FAMILY) || defined(__sun__) #define POW10(x) powf(10.0,x) #else #define POW10(x) pow10f(x) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_commonUI/DIA_prefs.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_commonUI/DIA_prefs.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_commonUI/DIA_prefs.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_commonUI/DIA_prefs.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -352,11 +352,44 @@ framePP.swallow(&fvzd); framePP.swallow(&fdring); framePP.swallow(&postProcStrength); - + + +// -- select language + typedef struct { const char *lang;const char *desc;}languageDescriptor; + uint32_t languageIndex=0; + languageDescriptor myLanguages[]={ + {"auto","System language"}, + {"en","English"}, + {"fr","Français"}, + {"de","German"}, + {"es","Spanish"}, + {"it","Italian"}, + {"ru","Pyckuu"}, + {"pl","Polish"}, + }; + uint32_t nbLanguages=sizeof(myLanguages)/sizeof(languageDescriptor); + char *currentLanguage; + int currentIndex=0; + if(!prefs->get(DEFAULT_LANGUAGE,¤tLanguage)) currentLanguage="auto"; + + diaMenuEntryDynamic **languagesMenuItems=new diaMenuEntryDynamic *[nbLanguages+1]; + for(int i=0;ilang,currentLanguage)) + currentIndex=i; + languagesMenuItems[i]=new diaMenuEntryDynamic(i,lg->desc,lg->lang); + } + languageIndex=currentIndex; + diaElemMenuDynamic menuLanguage(&languageIndex,QT_TRANSLATE_NOOP("adm","_Language"), nbLanguages, + languagesMenuItems,NULL); +//-- + + /* User Interface */ - diaElem *diaUser[]={&useSysTray,&menuMessage}; - diaElemTabs tabUser(QT_TRANSLATE_NOOP("adm","User Interface"),2,diaUser); + diaElem *diaUser[]={&useSysTray,&menuMessage,&menuLanguage}; + diaElemTabs tabUser(QT_TRANSLATE_NOOP("adm","User Interface"),3,diaUser); /* Automation */ @@ -508,6 +541,7 @@ // Alternate mp3 tag (haali) prefs->set(FEATURES_ALTERNATE_MP3_TAG,balternate_mp3_tag); + prefs->set(DEFAULT_LANGUAGE,myLanguages[languageIndex].lang); // Avisynth prefs->set(AVISYNTH_AVISYNTH_DEFAULTPORT,defaultPortAvisynth); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/include/ADM_edit.hxx avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/include/ADM_edit.hxx --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/include/ADM_edit.hxx 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/include/ADM_edit.hxx 2014-03-12 06:15:23.000000000 +0000 @@ -196,6 +196,8 @@ return _segments.undo(); } uint8_t resetSeg( void ); + bool copyToClipBoard(uint64_t startTime, uint64_t endTime); + bool pasteFromClipBoard(uint64_t currentTime); bool addFile (const char *name); int appendFile(const char *name); void closeFile(void); @@ -322,11 +324,16 @@ bool clearAudioTracks(void); /// remove all audio tracks bool addAudioTrack(int poolIndex); /// Add an audio track in the active tracks bool addExternalAudioTrack(const char *fileName); /// Add audio track from a file - void updateDefaultAudioTrack(void); + void updateDefaultAudioTrack(void); + + void seekFrame(int count); + void seekKeyFrame(int count); + void seekBlackFrame(int count); +public: + bool setVar(const char *key, const char *value); + const char *getVar(const char *key); + bool printEnv(void); - void seekFrame(int count); - void seekKeyFrame(int count); - void seekBlackFrame(int count); /********************************* /IEditor **********************************/ }; #endif diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/include/ADM_segment.h avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/include/ADM_segment.h --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/include/ADM_segment.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/include/ADM_segment.h 2014-03-12 06:15:23.000000000 +0000 @@ -133,6 +133,7 @@ { protected: ListOfSegments segments; + ListOfSegments clipboard; std::list undoSegments; ListOfVideos videos; bool updateStartTime(void); @@ -181,6 +182,9 @@ bool dtsFromPts(uint32_t refVideo,uint64_t pts,uint64_t *dts); bool LinearToRefTime(int segNo,uint64_t linear,uint64_t *refTime); + + bool copyToClipBoard(uint64_t startTime, uint64_t endTime); + bool pasteFromClipBoard(uint64_t currentTime); }; #endif diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/include/IEditor.h avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/include/IEditor.h --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/include/IEditor.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/include/IEditor.h 2014-03-12 06:15:23.000000000 +0000 @@ -102,5 +102,9 @@ virtual uint32_t getFrameSize(int count) = 0; virtual int setVideoCodecProfile(const char *codec, const char *profile)=0; virtual bool audioSetAudioPoolLanguage(int poolIndex, const char *language)=0; + // var + virtual bool setVar(const char *key, const char *value)=0; + virtual const char *getVar(const char *key)=0; + virtual bool printEnv(void)=0; }; #endif diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_edAudioPcm.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_edAudioPcm.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_edAudioPcm.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_edAudioPcm.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -153,7 +153,7 @@ if(!trk->codec->run(packetBuffer, packetBufferSize, dest, &nbOut)) { packetBufferSize=0; // consume - ADM_warning(ADM_PRINT_ERROR,"[Composer::getPCMPacket] Track %d:%x : codec failed failed\n", + ADM_warning("[Composer::getPCMPacket] Track %d:%x : codec failed failed\n", myTrackNumber,trk); return false; } diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_edAudioTrackExternal.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_edAudioTrackExternal.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_edAudioTrackExternal.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_edAudioTrackExternal.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -137,6 +137,7 @@ { case WAV_PCM: case WAV_AC3: + case WAV_MP2: case WAV_MP3: break; default: diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_edCheckForInvalidPts.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_edCheckForInvalidPts.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_edCheckForInvalidPts.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_edCheckForInvalidPts.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -14,6 +14,7 @@ * (at your option) any later version. * * * ***************************************************************************/ +#include #include "ADM_cpp.h" #include "ADM_default.h" #include "A_functions.h" @@ -108,6 +109,27 @@ return true; } /** + * \fn checkTiming + * @param list + * @param limit + * @return + */ +static bool checkTiming(std::vector &list, uint64_t limit) +{ + int n=list.size(); + int good=0,bad=0; + for(int i=0;igetVideoStreamHeader()->dwLength; int good=0,bad=0,skipped=0; uint64_t dtsCeil= (timeIncrementUs*18)/10; + std::vector dtsList,ptsList; ADM_info("Checking for doubled FPS.., time increment ceiling = %d\n",(int)dtsCeil); - for(int i=0;igetPtsDts(i,&pts,&dts); - hdr->getPtsDts(i+1,&pts,&dts2); - if(dts==ADM_NO_PTS || dts2==ADM_NO_PTS) - { - skipped++; - continue; - } - if((dts2-dts)< dtsCeil) - bad++; - else - good++; + + if(dts!=ADM_NO_PTS) + dtsList.push_back(dts); + if(pts!=ADM_NO_PTS) + ptsList.push_back(pts); } - ADM_info("Out of %d frames, we have :\n",totalFrames); - ADM_info("Bad : %d\n",bad); - ADM_info("Good : %d\n",good); - ADM_info("Skipped : %d\n",skipped); - int total=good+bad+skipped; - if(!total) return false; - if(bad==0 && good*100>40*total) - { - ADM_info(" Looks like doubled fps\n"); - return true; - + std::sort (dtsList.begin(), dtsList.end()); + std::sort (ptsList.begin(), ptsList.end()); + ADM_info("Checking DTS...\n"); + bool okDts=checkTiming(dtsList,dtsCeil); + ADM_info("Checking PTS...\n"); + bool okPts=checkTiming(ptsList,dtsCeil); + + if(okDts && okPts) + { + ADM_info("We can safely halve fps\n"); + }else + { + ADM_info("Cannot halve fps\n"); } - return false; + return okDts && okPts; } // EOF diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_edit.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_edit.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_edit.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_edit.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -25,6 +25,7 @@ #include #include +#include #include "fourcc.h" #include "ADM_edit.hxx" @@ -73,6 +74,18 @@ */ #define YOURAUDIO(x) _videos[x].audioTracks[_videos[x].currentAudioStream] + +bool ADM_Composer::copyToClipBoard(uint64_t startTime, uint64_t endTime) +{ + return _segments.copyToClipBoard(startTime,endTime); + +} +bool ADM_Composer::pasteFromClipBoard(uint64_t currentTime) +{ + return _segments.pasteFromClipBoard(currentTime); + +} + /** \fn resetSeg \brief Redo a 1:1 mapping between ref video and segment @@ -749,4 +762,54 @@ v->_aviheader->getFrameSize(frame,&sz); return sz; } + +static std::map scriptEnv; + +/** + * \fn setVar + * @param key + * @param value + * @return + */ +bool ADM_Composer::setVar(const char *key, const char *value) +{ + std::map::iterator it; + it=scriptEnv.find(std::string(key)); + if(scriptEnv.end() !=it) + { + scriptEnv.erase(it); + } + scriptEnv.insert(std::pair(key,value)); + return true; +} +/** + * \fn getVar + * @param key + * @return + */ +const char *ADM_Composer::getVar(const char *key) +{ + std::map::iterator it; + it=scriptEnv.find(std::string(key)); + if(scriptEnv.end() !=it) + { + return scriptEnv[key].c_str(); // ?? + } + return NULL; +} +/** + * \fn printEnv + * @param + * @return + */ +bool ADM_Composer::printEnv(void) +{ + std::map::iterator it; + for(it=scriptEnv.begin();it!=scriptEnv.end();it++) + { + printf("%s => %s\n",it->first.c_str(),it->second.c_str()); + } + return true; +} + // EOF diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_segment.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_segment.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_editor/src/ADM_segment.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_editor/src/ADM_segment.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -26,6 +26,14 @@ #include "ADM_audiocodec/ADM_audiocodec.h" #include "ADM_codec.h" #include "DIA_coreToolkit.h" +#include "ADM_vidMisc.h" + +#if 1 +#define aprintf printf +#else +#define aprintf(...) {} +#endif + ADM_EditorSegment::ADM_EditorSegment(void) { } @@ -256,7 +264,7 @@ bool ADM_EditorSegment::undo(void) { if(undoSegments.empty()) return false; - + clipboard.clear(); segments=undoSegments.back(); undoSegments.pop_back(); updateStartTime(); @@ -337,7 +345,10 @@ bool ADM_EditorSegment::updateStartTime(void) { int n=segments.size(); + if(!n) return true; + uint64_t t=0; + t=segments[0]._startTimeUs; for(int i=0;iframeTime) @@ -716,7 +734,9 @@ for(int i=0;igetRefVideo(seg->_reference); if(seg->_durationUs==0) index=i; + if(seg->_refStartTimeUs==0 && seg->_durationUs==vid->firstFramePts) index=i; } if(index==-1) break; segments.erase(segments.begin()+index); @@ -759,4 +779,90 @@ *refTime=(uint64_t )time; return true; } +/** + * \fn copyToClipBoard + * \Brief copy the section between startTime and endTime to clipboard + * @param startTime + * @param endTime + * @return + */ +bool ADM_EditorSegment::copyToClipBoard(uint64_t startTime, uint64_t endTime) +{ + ADM_info("Copy to clipboard from %s",ADM_us2plain(startTime)); + ADM_info("to %s\n",ADM_us2plain(endTime)); + uint32_t startSeg,endSeg; + uint64_t startSegTime,endSegTime; + convertLinearTimeToSeg( startTime, &startSeg,&startSegTime); + convertLinearTimeToSeg( endTime, &endSeg,&endSegTime); + clipboard.clear(); + for(int seg=startSeg;seg<=endSeg;seg++) + { + _SEGMENT s=segments[seg]; + aprintf("Adding segment %d to clipboard\n",seg); + if(s._startTimeUs<=startTime && (s._startTimeUs+s._durationUs)>startTime) + { + // need to refine 1st seg + aprintf("Marker A is here\n"); + uint64_t offset=startTime-s._startTimeUs; + s._refStartTimeUs+=offset; + s._durationUs-=offset; // take into account the part we chopped + } + if(s._startTimeUs<=endTime && (s._startTimeUs+s._durationUs)>endTime) + { + aprintf("Marker B is here\n"); + // need to refine last seg + uint64_t offset=endTime-s._startTimeUs; + s._durationUs=offset; + } + // TODO refine timing for 1st/last/duration/... + clipboard.push_back(s); + } + return false; +} +/** + * \fn pasteFromClipBoard + * \brief instert clipboard at currentTime position + * @param currentTime + * @return + */ +bool ADM_EditorSegment::pasteFromClipBoard(uint64_t currentTime) +{ + ADM_info("Pasting from clipboard to %s\n",ADM_us2plain(currentTime)); + uint32_t startSeg; + uint64_t startSegTime; + convertLinearTimeToSeg( currentTime, &startSeg,&startSegTime); + ListOfSegments newSegs; + int n=segments.size(); + for(int i=0;isetVar(var,value); return 1; } @@ -594,26 +571,6 @@ */ -char *script_getVar(char *in, int *r) -{ - - printf("Get var called with in=[%s]\n",in); - for(uint32_t i=0;iset(FEATURES_REUSE_2PASS_LOG,true); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_libva.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_libva.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_libva.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_libva.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -243,13 +243,10 @@ _context->hwaccel_context = va_context; nbSurface=0; - uint8_t *extraCopy=NULL; + if(extraDataLen) { - extraCopy=(uint8_t *)alloca(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - _context->extradata = (uint8_t *) extraCopy; + _context->extradata = (uint8_t *) _extraDataCopy; _context->extradata_size = (int) extraDataLen; } diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_vdpau.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_vdpau.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_vdpau.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_vdpau.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -281,19 +281,13 @@ { alive=true; scratch=NULL; - uint8_t *extraCopy=NULL; - if(extraDataLen) - { - extraCopy=(uint8_t *)alloca(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - } + _context->opaque = this; _context->get_buffer = ADM_VDPAUgetBuffer; _context->release_buffer = ADM_VDPAUreleaseBuffer; _context->draw_horiz_band = draw; _context->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; - _context->extradata = (uint8_t *) extraCopy; + _context->extradata = (uint8_t *) _extraDataCopy; _context->extradata_size = (int) extraDataLen; _context->get_format = vdpauGetFormat; vdpau=(void *)new vdpauContext; @@ -385,11 +379,13 @@ } VDPAU->freeQueue.clear(); } - ADM_info("[VDPAU] Destroying decoder\n"); - if(VDP_STATUS_OK!=admVdpau::decoderDestroy(VDPAU->vdpDecoder)) + if (VDPAU->vdpDecoder) { + ADM_info("[VDPAU] Destroying decoder\n"); + if(VDP_STATUS_OK!=admVdpau::decoderDestroy(VDPAU->vdpDecoder)) ADM_error("Error destroying VDPAU decoder\n"); - delete VDPAU; - vdpau=NULL; + } + delete VDPAU; + vdpau=NULL; } /** \fn uncompress diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_xvba.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_xvba.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_xvba.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_xvba.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -211,13 +211,10 @@ _context->pix_fmt = AV_PIX_FMT_XVBA_VLD; - uint8_t *extraCopy=NULL; + if(extraDataLen) { - extraCopy=(uint8_t *)alloca(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - _context->extradata = (uint8_t *) extraCopy; + _context->extradata = (uint8_t *) _extraDataCopy; _context->extradata_size = (int) extraDataLen; } diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/common/gui_main.cpp avidemux2.6-2.6.8~ppa1/avidemux/common/gui_main.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/common/gui_main.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/common/gui_main.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -453,11 +453,27 @@ break; } case ACT_Copy: - brokenAct(); -// video_body->copyToClipBoard (frameStart,frameEnd); + { + uint64_t markA,markB; + markA=video_body->getMarkerAPts(); + markB=video_body->getMarkerBPts(); + if(markA>markB) + { + uint64_t p=markA; + markA=markB; + markB=p; + } + video_body->copyToClipBoard (markA,markB); break; + } case ACT_Paste: - brokenAct(); + { + uint64_t currentPts=video_body->getCurrentFramePts(); + video_body->pasteFromClipBoard(currentPts); + video_body->getVideoInfo (avifileinfo); + A_ResetMarkers(); + ReSync (); + } break; break; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/qt4/ADM_userInterfaces/ADM_dialog/Q_audioTracks.cpp avidemux2.6-2.6.8~ppa1/avidemux/qt4/ADM_userInterfaces/ADM_dialog/Q_audioTracks.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/qt4/ADM_userInterfaces/ADM_dialog/Q_audioTracks.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/qt4/ADM_userInterfaces/ADM_dialog/Q_audioTracks.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -274,8 +274,10 @@ bool audioTrackQt4::updateActive(void) { // 1 - check for duplicates - int map[NB_MENU]; - memset(map,0,sizeof(map)); + int map[32]; // The size is related to the INPUT number of tracks, not output thx Rickard + for(int i=0;i<32;i++) + map[i]=0; + for(int i=0;ienabled[i]->checkState()==Qt::Checked) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/qt4/ADM_userInterfaces/ui_support.cpp avidemux2.6-2.6.8~ppa1/avidemux/qt4/ADM_userInterfaces/ui_support.cpp --- avidemux2.6-2.6.7~ppa3/avidemux/qt4/ADM_userInterfaces/ui_support.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/qt4/ADM_userInterfaces/ui_support.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -16,6 +16,7 @@ #include "ADM_files.h" #include "DIA_uiTypes.h" #include "ADM_coreTranslator.h" +#include "prefs.h" extern QWidget *QuiMainWindows; #define MAX_UNLOADED_MSG_LENGTH 400 @@ -76,8 +77,23 @@ void loadTranslator(void) { - printf("\n[Locale] Locale: %s\n", QLocale::system().name().toUtf8().constData()); - + + char *lang=NULL; + bool autoSelect=true; + if(prefs->get(DEFAULT_LANGUAGE,&lang)) + { + if(lang && strlen(lang)>0 && strcmp(lang,"auto")) + autoSelect=false; + } + if(autoSelect) + { + ADM_info("Using system language\n"); + lang=ADM_strdup(QLocale::system().name().toUtf8().constData()); + }else + { + ADM_info("Language forced \n"); + } + ADM_info("Initializing language %s\n",lang); #ifdef __APPLE__ QString appdir = QCoreApplication::applicationDirPath() + "/../share/avidemux6/i18n/"; @@ -86,9 +102,10 @@ #else QString appdir = ADM_getInstallRelativePath("share","avidemux6","i18n"); #endif + QString languageFile=QString(lang); int nbLoaded=0; - nbLoaded+=loadTranslation(&qtTranslator, appdir + "qt_" + QLocale::system().name()); - nbLoaded+=loadTranslation(&avidemuxTranslator, appdir + "avidemux_" + QLocale::system().name()); + nbLoaded+=loadTranslation(&qtTranslator, appdir + "qt_" + languageFile); + nbLoaded+=loadTranslation(&avidemuxTranslator, appdir + "avidemux_" + languageFile); translatorLoaded = true; if(!nbLoaded) // Nothing to translate.. return; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/winInstaller/avidemux_cross64.nsi avidemux2.6-2.6.8~ppa1/avidemux/winInstaller/avidemux_cross64.nsi --- avidemux2.6-2.6.7~ppa3/avidemux/winInstaller/avidemux_cross64.nsi 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/winInstaller/avidemux_cross64.nsi 2014-03-12 06:15:23.000000000 +0000 @@ -31,7 +31,7 @@ !define EXEDIR "${NSIDIR}/install" !define CORE_VERSION "2.6" -!define POINT_RELEASE "7" +!define POINT_RELEASE "8" !define PRODUCT_VERSION "${CORE_VERSION}.${POINT_RELEASE}.${SVN_VERSION}" !define PRODUCT_NAME "Avidemux ${CORE_VERSION} - 64bits" !define PRODUCT_FULLNAME "Avidemux ${PRODUCT_VERSION} (${BUILD_BITS}-bit Release)" diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/winInstaller/avidemux_cross.nsi avidemux2.6-2.6.8~ppa1/avidemux/winInstaller/avidemux_cross.nsi --- avidemux2.6-2.6.7~ppa3/avidemux/winInstaller/avidemux_cross.nsi 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/winInstaller/avidemux_cross.nsi 2014-03-12 06:15:23.000000000 +0000 @@ -33,7 +33,7 @@ !define EXEDIR "${NSIDIR}/install" !define CORE_VERSION "2.6" -!define POINT_RELEASE "7" +!define POINT_RELEASE "8" !define PRODUCT_VERSION "${CORE_VERSION}.${POINT_RELEASE}.${SVN_VERSION}" !define PRODUCT_NAME "Avidemux ${CORE_VERSION}" !define PRODUCT_FULLNAME "Avidemux ${PRODUCT_VERSION} (${BUILD_BITS}-bit Release)" @@ -387,22 +387,22 @@ SetOutPath $INSTDIR\plugins\audioDecoder ${File} ${ADM_DIR}/plugins/audioDecoder/libADM_ad_ms_adpcm.dll ${MementoSectionEnd} - #${MementoSection} "AMR-NB" SecAudDecOpencoreAmrNb - #SectionIn 1 2 - #SetOverwrite on - #SetOutPath $INSTDIR\plugins\audioDecoder - #${File} ${ADM_DIR}/plugins/audioDecoder/libADM_ad_opencore_amrnb.dll - #SetOutPath $INSTDIR - #${File} ${ADM_DIR}/libopencore-amrnb-*.dll - #${MementoSectionEnd} - #${MementoSection} "AMR-WB" SecAudDecOpencoreAmrWb - #SectionIn 1 2 - #SetOverwrite on - #SetOutPath $INSTDIR\plugins\audioDecoder - #${File} ${ADM_DIR}/plugins/audioDecoder/libADM_ad_opencore_amrwb.dll - #SetOutPath $INSTDIR - #${File} ${ADM_DIR}/libopencore-amrwb-*.dll - #${MementoSectionEnd} + ${MementoSection} "AMR-NB" SecAudDecOpencoreAmrNb + SectionIn 1 2 + SetOverwrite on + SetOutPath $INSTDIR\plugins\audioDecoder + ${File} ${ADM_DIR}/plugins/audioDecoder/libADM_ad_opencore_amrnb.dll + SetOutPath $INSTDIR + ${File} ${ADM_SYSDIR}/libopencore-amrnb-*.dll + ${MementoSectionEnd} + ${MementoSection} "AMR-WB" SecAudDecOpencoreAmrWb + SectionIn 1 2 + SetOverwrite on + SetOutPath $INSTDIR\plugins\audioDecoder + ${File} ${ADM_DIR}/plugins/audioDecoder/libADM_ad_opencore_amrwb.dll + SetOutPath $INSTDIR + ${File} ${ADM_SYSDIR}/libopencore-amrwb-*.dll + ${MementoSectionEnd} ${MementoSection} "MP2, MP3 (MAD)" SecAudDecMad SectionIn 1 2 SetOverwrite on @@ -597,12 +597,12 @@ SetOutPath $INSTDIR\plugins\muxers ${File} ${ADM_DIR}/plugins/muxers/libADM_mx_mp4.dll ${MementoSectionEnd} - #${MementoSection} "MP4 (MP4v2)" SecMuxMp4v2 - #SectionIn 1 2 - #SetOverwrite on - #SetOutPath $INSTDIR\plugins\muxers - #${File} ${ADM_DIR}/plugins/muxers/libADM_mx_mp4v2.dll - #${MementoSectionEnd} + ${MementoSection} "MP4 (MP4v2)" SecMuxMp4v2 + SectionIn 1 2 + SetOverwrite on + SetOutPath $INSTDIR\plugins\muxers + ${File} ${ADM_DIR}/plugins/muxers/libADM_mx_mp4v2.dll + ${MementoSectionEnd} ${MementoSection} "MPEG-PS" SecMuxLavMpegPs SectionIn 1 2 SetOverwrite on diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/winInstaller/Change Log.html avidemux2.6-2.6.8~ppa1/avidemux/winInstaller/Change Log.html --- avidemux2.6-2.6.7~ppa3/avidemux/winInstaller/Change Log.html 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/winInstaller/Change Log.html 2014-03-12 06:15:23.000000000 +0000 @@ -51,7 +51,33 @@

What's New in Avidemux

-

2.6.7

+

2.6.8

+
    +
  • Image/export: Proper initialization of Qz for jpeg export
  • +
  • UI : Add an override menu to force language
  • +
  • tinypy : Add support for os.environ
  • +
  • x264 : Improved settings (tobias)
  • +
  • Win32 : Fix crash when having an audio problem
  • +
  • Win32 : Re-add mp4v2 to installer files
  • +
  • Audio/FAAC : Fix channel mapping when source is mono
  • +
  • Audio/AMR : Re-enabled AMR
  • +
  • Audio/lavc : Fixed encoding for codec not supporting planar (MP2)
  • +
  • Audio : Fixed importing MP2 audio detected as MP3
  • +
  • Editor : Fix deleting chunks of the video leading to seek errors
  • +
  • Editor : Initial copy/paste support
  • +
  • Editor/audio: Fix issue when source has more than 4 tracks
  • +
  • Editor : Better detection of double fps input files
  • +
  • TS/Demux : Brute force eac3 probe
  • +
  • TS/Demux : Better initialization, avoid dropping audio
  • +
  • MP4/Demux : Fix management of PCM audio
  • +
  • Mkv/Demux : Proper re-indexing for mpeg2 in mkv
  • +
  • Mp4v2/Mux : Add fast start mode back
  • +
  • OpenSolaris : Some fixes by pfelecan
  • +
  • Subtitles : Update libass + very simple srt2ssa converter
  • +
  • OsX : Enables more optional codecs...
  • +
  • avsfilte : Performance Improvements (fahr)
  • +
+

2.6.7

  • Windows : Better management of non ascii filename with x264
  • Images : Better support for bmp and jpeg
  • diff -Nru avidemux2.6-2.6.7~ppa3/avidemux/winInstaller/What's New.html avidemux2.6-2.6.8~ppa1/avidemux/winInstaller/What's New.html --- avidemux2.6-2.6.7~ppa3/avidemux/winInstaller/What's New.html 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux/winInstaller/What's New.html 2014-03-12 06:15:23.000000000 +0000 @@ -52,15 +52,29 @@

    What's New in Avidemux

      -
    • Windows : Better management of non ascii filename with x264
    • -
    • Images : Better support for bmp and jpeg
    • -
    • Auto : Fixed PSP auto script (LJ)
    • -
    • Packages: Better RPM generation (mit)
    • -
    • Audio : Correct handling of 8Bits PCM in mp4/mov
    • -
    • Build : Support for cmake 2.8.12 (2.8.13) (ajschult)
    • -
    • mkv : Fixed seeking in mkv/h264
    • -
    • TS/Audio: Extend support for SBR in AAC/LATM
    • -
    • TS/H264 : Split at NALU boundaries, sometimes it was off by one byte
    • +
    • Image/export: Proper initialization of Qz for jpeg export
    • +
    • UI : Add an override menu to force language
    • +
    • tinypy : Add support for os.environ
    • +
    • x264 : Improved settings (tobias)
    • +
    • Win32 : Fix crash when having an audio problem
    • +
    • Win32 : Re-add mp4v2 to installer files
    • +
    • Audio/FAAC : Fix channel mapping when source is mono
    • +
    • Audio/AMR : Re-enabled AMR
    • +
    • Audio/lavc : Fixed encoding for codec not supporting planar (MP2)
    • +
    • Audio : Fixed importing MP2 audio detected as MP3
    • +
    • Editor : Fix deleting chunks of the video leading to seek errors
    • +
    • Editor : Initial copy/paste support
    • +
    • Editor/audio: Fix issue when source has more than 4 tracks
    • +
    • Editor : Better detection of double fps input files
    • +
    • TS/Demux : Brute force eac3 probe
    • +
    • TS/Demux : Better initialization, avoid dropping audio
    • +
    • MP4/Demux : Fix management of PCM audio
    • +
    • Mkv/Demux : Proper re-indexing for mpeg2 in mkv
    • +
    • Mp4v2/Mux : Add fast start mode back
    • +
    • OpenSolaris : Some fixes by pfelecan
    • +
    • Subtitles : Update libass + very simple srt2ssa converter
    • +
    • OsX : Enables more optional codecs...
    • +
    • avsfilte : Performance Improvements (fahr)

    diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_core/src/ADM_misc.cpp avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_core/src/ADM_misc.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_core/src/ADM_misc.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_core/src/ADM_misc.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -214,11 +214,11 @@ uint32_t ms=(uint32_t)(ams/1000); uint32_t hh,mm,ss,mms; if(ams==ADM_NO_PTS) - sprintf(buffer," xx:xx:xx,xxx "); + sprintf(buffer,"xx:xx:xx,xxx"); else { ms2time(ms,&hh,&mm,&ss,&mms); - sprintf(buffer," %02"PRIu32":%02"PRIu32":%02"PRIu32",%03"PRIu32" ",hh,mm,ss,mms); + sprintf(buffer,"%02"PRIu32":%02"PRIu32":%02"PRIu32",%03"PRIu32,hh,mm,ss,mms); } return buffer; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreAudio/src/ADM_audioIdentify.cpp avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreAudio/src/ADM_audioIdentify.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreAudio/src/ADM_audioIdentify.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreAudio/src/ADM_audioIdentify.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -72,8 +72,8 @@ // fill in info info.frequency=mp2info.samplerate; info.byterate=(mp2info.bitrate>>3)*1000; - if(mp2info.layer==1) info.encoding=WAV_MP2; - else info.encoding=WAV_MP3; + if(mp2info.layer==3) info.encoding=WAV_MP3; + else info.encoding=WAV_MP2; switch(mp2info.mode) { case 1: // Joint stereo diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreImage/src/ADM_imageSave.cpp avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreImage/src/ADM_imageSave.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreImage/src/ADM_imageSave.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreImage/src/ADM_imageSave.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -173,6 +173,7 @@ context->time_base.num=1; context->width=_width; context->height=_height; + context->flags |= CODEC_FLAG_QSCALE; r=avcodec_open(context, codec); if(r<0) { @@ -193,7 +194,7 @@ // Grab a temp buffer // Encode! - context->flags |= CODEC_FLAG_QSCALE; + frame.quality = (int) floor (FF_QP2LAMBDA * 2+ 0.5); byteBuffer.setSize(_width*_height*4); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreSubtitles/CMakeLists.txt avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreSubtitles/CMakeLists.txt --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreSubtitles/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreSubtitles/CMakeLists.txt 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1 @@ +ADD_SUBDIRECTORY(src) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreSubtitles/inc/ADM_coreSubtitles.h avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreSubtitles/inc/ADM_coreSubtitles.h --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreSubtitles/inc/ADM_coreSubtitles.h 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreSubtitles/inc/ADM_coreSubtitles.h 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,46 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#pragma once +#include +#include +typedef std::vector ListOfText; +/** + * \class subtitleTextEntry + */ +class subtitleTextEntry +{ +public: + uint64_t start; + uint64_t stop; + ListOfText texts; +}; +typedef std::vector ListOfSubtitleLines; +/** + * \class ADM_subtitle + */ +class ADM_subtitle +{ + typedef enum + { + SUB_TYPE_NONE, + SUB_TYPE_SRT, + SUB_TYPE_SSA + }ADM_SUBTITLE_TYPE; +protected: + ADM_SUBTITLE_TYPE _type; + ListOfSubtitleLines _list; +public: + ADM_subtitle(); + virtual ~ADM_subtitle(); + bool load(const char *subtitleFile); + bool dump(void); + bool saveAsSSA(const char *out); +public: + bool srt2ssa(); +}; \ No newline at end of file diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreSubtitles/src/ADM_coreSubtitles.cpp avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreSubtitles/src/ADM_coreSubtitles.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreSubtitles/src/ADM_coreSubtitles.cpp 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreSubtitles/src/ADM_coreSubtitles.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,169 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "ADM_default.h" +#include "ADM_coreSubtitles.h" +#include "ADM_vidMisc.h" + +namespace ADM_sub +{ +extern bool loadSrt(const char *file,ListOfSubtitleLines &lines); +extern bool srt2ssa(subtitleTextEntry &in,subtitleTextEntry &out); +}; + +/** + * + * @param subtitleFile + * @return + */ +ADM_subtitle:: ADM_subtitle() +{ + _type=SUB_TYPE_NONE; +} +/** + * + * @param subtitleFile + * @return + */ +ADM_subtitle::~ADM_subtitle() +{ + +} +/** + * + * @param subtitleFile + * @return + */ +bool ADM_subtitle::load(const char *subtitleFile) +{ + int l=strlen(subtitleFile); + if(l<4) + { + ADM_warning("Subtitle file is too short <%s>\n",subtitleFile); + return false; + } + const char *ext=subtitleFile+l-3; + if(!strcasecmp(ext,"srt")) + { + bool r=ADM_sub::loadSrt(subtitleFile,_list); + if(!r) + { + return false; + } + _type=SUB_TYPE_SRT; + return true; + } + ADM_warning("Unknown extension <%s>, or not supported\n",ext); + return false; +} +/** + * \fn dump + * @return + */ +bool ADM_subtitle::dump(void) +{ + int n=_list.size(); + for(int i=0;i",ADM_us2plain(e.start)); + printf(" %s :",ADM_us2plain(e.stop)); + int m=e.texts.size(); + for(int j=0;j<%s> \n",e.texts[j].c_str()); + } + return true; +} + +/** + */ +bool ADM_subtitle::srt2ssa() +{ + ListOfSubtitleLines converted; + if(_type!=SUB_TYPE_SRT) + { + ADM_warning("srt2ssa: Input file is not SRT\n"); + return false; + } + int n=_list.size(); + for(int i=0;i\n",out); + return false; + } + writeSSAHeader(file); + for(int i=0;i + +*/ + + +#include "ADM_default.h" +#include "ADM_coreSubtitles.h" +#include "ADM_vidMisc.h" +namespace ADM_sub +{ + + +static const char *ADMus2Time(uint64_t ams) +{ +static char buffer[256]; +uint32_t ms=(uint32_t)(ams/1000); + uint32_t hh,mm,ss,mms; + if(ams==ADM_NO_PTS) + sprintf(buffer,"xx:xx:xx.xxx"); + else + { + ms2time(ms,&hh,&mm,&ss,&mms); + sprintf(buffer,"%01"PRIu32":%02"PRIu32":%02"PRIu32".%03"PRIu32,hh,mm,ss,mms); + } + return buffer; + +} + +#ifndef DIR_SEP +# ifdef WIN32 +# define DIR_SEP '\\' +# define DEFAULT_FONT_DIR "c:" +# else +# define DIR_SEP '/' +# define DEFAULT_FONT_DIR "/usr/share/fonts/truetype/" +# endif +#endif +//***************** + + + +/** + * \fn srt2ssa + * @param in + * @param out + * @return + * + * Dialogue: 0,0:41:49.86,0:41:56.95,Default,,0000,0000,0000,,Transcript : www.ydy.com/bbs | Benj!\nResynchro : Benj!. + * + */ +bool srt2ssa(subtitleTextEntry &in,subtitleTextEntry &out) +{ + char buffer[1024]; + char buffer2[1024]; + std::string startTime=std::string(ADMus2Time(in.start)); + std::string endTime=std::string(ADMus2Time(in.stop)); + std::string result; + + sprintf(buffer,"Dialogue: 0,%s,%s,Default,,0000,0000,0000,,",startTime.c_str(),endTime.c_str()); + int m=in.texts.size(); + if(m) + { + strcpy(buffer2,in.texts[0].c_str()); + for(int i=1;i 00:00:30,800 + * La prison m'a permis de rencontrer beaucoup de personnes + * + * @param in + * @param string + * @return + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "ADM_default.h" +#include "ADM_coreSubtitles.h" + +#define HOLD_ON_TIMER (3*1000*1000LL) + +namespace ADM_sub +{ + +typedef enum +{ + STATE_IDLE=0, + STATE_LINENO, + STATE_TIMING, + STATE_DATA +}SRT_STATE; + +/** + * \fn splitSrtTiming + * @param start + * @param end + * @param str + * @return + * + * 00:00:43,800 --> 00:00:48,000 + + */ +static uint64_t split2us(const int h2,const int m2,const int s2,const int ms2) +{ + uint64_t r=h2; + r=(r*60)+m2; + r=(r*60)+s2; + r=(r*1000)+ms2; + r=r*1000; + return r; +} +/** + * \fn splitSrtTiming + * @param str + * @param start + * @param end + * @return + */ +static bool splitSrtTiming(const char *str,uint64_t &start,uint64_t &end ) +{ + int h1,h2,m1,m2,s1,s2,ms1,ms2; + int n=sscanf(str,"%d:%d:%d,%d --> %d:%d:%d,%d",&h1,&m1,&s1,&ms1,&h2,&m2,&s2,&ms2); + if(n!=8) + { + return false; + } + start=split2us(h1,m1,s1,ms1); + end=split2us(h2,m2,s2,ms2); + return true; +} + + +/** + * \fn updateTiming + * \brief srt does not provide 'end display' timeing information, make a guess + */ +static bool updateSrtTiming(ListOfSubtitleLines &lines) +{ + int n=lines.size(); + for(int i=0;i=next.start) limit=next.start-10000; + lines.at(i).stop=limit; + } + if(n) + lines[n-1].stop=lines[n-1].start+HOLD_ON_TIMER; + return true; + + +} +/** + * \fn loadSrt + * @param file + * @param lines + * @return + */ +bool loadSrt(const char *file,ListOfSubtitleLines &lines) +{ + FILE *fd=ADM_fopen(file,"rt"); + if(!fd) + { + ADM_warning("Cannot open subtitle %s\n,file"); + return false; + } + bool status=true; + char buffer[1024]; + SRT_STATE state=STATE_LINENO; + subtitleTextEntry entry; + while(1) + { + if(!fgets(buffer,1023,fd)) + { + break; + } + int length=strlen(buffer); + // remove trailing CR/LF + char *p=buffer+length-1; + while((*p=='\n' || *p=='\r')&& (p>buffer)) p--; + p[1]=0; + length=strlen(buffer); + + int lineno; + printf("%d\n",state); + switch(state) + { + case STATE_LINENO: + if(!length) continue; + lineno=atoi(buffer); + state=STATE_TIMING; + break; + case STATE_TIMING: + if(length<2) + { + ADM_warning("Inconsistent file\n"); + status=false; + break; + } + uint64_t start,end; + if(!splitSrtTiming(buffer,start,end)) + { + ADM_warning("Inconsistent timing line\n"); + status=false; + break; + } + entry.start=start; + entry.stop=end; + entry.texts.clear(); + state=STATE_DATA; + break; + case STATE_DATA: + if(length<2) + { + lines.push_back(entry); + entry.texts.clear(); + state=STATE_LINENO; + } + + entry.texts.push_back(std::string(buffer)); + break; + } + } + fclose(fd); + ADM_info("%d entries loaded\n",lines.size()); + //updateSrtTiming(lines); + return true; +} +} \ No newline at end of file diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreSubtitles/src/CMakeLists.txt avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreSubtitles/src/CMakeLists.txt --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreSubtitles/src/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreSubtitles/src/CMakeLists.txt 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,7 @@ +SET(ADM_core_subtitles_SRCS ADM_coreSubtitles.cpp ADM_subLoader.cpp ADM_subConvert.cpp) +INCLUDE_DIRECTORIES(../inc) + +# We force the use of fontconfig +ADM_ADD_SHARED_LIBRARY(ADM_coreSubtitle ${ADM_core_subtitles_SRCS}) +TARGET_LINK_LIBRARIES(ADM_coreSubtitle ADM_core6 ) +ADM_INSTALL_LIB(ADM_coreSubtitle) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/include/prefs2_list.h avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/include/prefs2_list.h --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/include/prefs2_list.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/include/prefs2_list.h 2014-03-12 06:15:23.000000000 +0000 @@ -35,6 +35,7 @@ DEFAULT_POSTPROC_TYPE, //uint32_t DEFAULT_POSTPROC_VALUE, //uint32_t DEFAULT_DOWNMIXING, //uint32_t +DEFAULT_LANGUAGE, //string MPEGSPLIT_AUTOSPLIT, //uint32_t AVISYNTH_AVISYNTH_ALWAYS_ASK, //bool AVISYNTH_AVISYNTH_DEFAULTPORT, //uint32_t diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2.conf avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2.conf --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2.conf 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2.conf 2014-03-12 06:15:23.000000000 +0000 @@ -67,7 +67,7 @@ uint32_t:postproc_type, 3, 0, 7 uint32_t:postproc_value, 3, 0, 5 uint32_t:downmixing, 2, 0, 2 - +string:language, "" } # uint32_t:mpegsplit_autosplit, 790, 400, 5000 diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -37,6 +37,7 @@ {"Default.postproc_type",offsetof(my_prefs_struct,Default.postproc_type),"uint32_t",ADM_param_uint32_t}, {"Default.postproc_value",offsetof(my_prefs_struct,Default.postproc_value),"uint32_t",ADM_param_uint32_t}, {"Default.downmixing",offsetof(my_prefs_struct,Default.downmixing),"uint32_t",ADM_param_uint32_t}, + {"Default.language",offsetof(my_prefs_struct,Default.language),"char *",ADM_param_string}, {"mpegsplit_autosplit",offsetof(my_prefs_struct,mpegsplit_autosplit),"uint32_t",ADM_param_uint32_t}, {"avisynth.avisynth_always_ask",offsetof(my_prefs_struct,avisynth.avisynth_always_ask),"bool",ADM_param_bool}, {"avisynth.avisynth_defaultport",offsetof(my_prefs_struct,avisynth.avisynth_defaultport),"uint32_t",ADM_param_uint32_t}, diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2.h avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2.h --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2.h 2014-03-12 06:15:23.000000000 +0000 @@ -50,6 +50,7 @@ uint32_t postproc_type; uint32_t postproc_value; uint32_t downmixing; + char * language; }Default; uint32_t mpegsplit_autosplit; struct { diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2_json.cpp avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2_json.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2_json.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2_json.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -53,6 +53,7 @@ json.addUint32("postproc_type",key->Default.postproc_type); json.addUint32("postproc_value",key->Default.postproc_value); json.addUint32("downmixing",key->Default.downmixing); +json.addString("language",key->Default.language); json.endNode(); json.addUint32("mpegsplit_autosplit",key->mpegsplit_autosplit); json.addNode("avisynth"); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2_pref.h avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2_pref.h --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/prefs2_pref.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/prefs2_pref.h 2014-03-12 06:15:23.000000000 +0000 @@ -48,6 +48,7 @@ { DEFAULT_POSTPROC_TYPE,"Default.postproc_type" ,ADM_param_uint32_t ,"3", 0, 7}, { DEFAULT_POSTPROC_VALUE,"Default.postproc_value" ,ADM_param_uint32_t ,"3", 0, 5}, { DEFAULT_DOWNMIXING,"Default.downmixing" ,ADM_param_uint32_t ,"2", 0, 2}, +{ DEFAULT_LANGUAGE,"Default.language" ,ADM_param_string ,"", 0, 0}, { MPEGSPLIT_AUTOSPLIT,"mpegsplit_autosplit" ,ADM_param_uint32_t ,"790", 400, 5000}, { AVISYNTH_AVISYNTH_ALWAYS_ASK,"avisynth.avisynth_always_ask" ,ADM_param_bool ,"0", 0, 1}, { AVISYNTH_AVISYNTH_DEFAULTPORT,"avisynth.avisynth_defaultport" ,ADM_param_uint32_t ,"9999", 1024, 65535}, diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/update_prefs.sh avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/update_prefs.sh --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreUtils/src/update_prefs.sh 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreUtils/src/update_prefs.sh 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,5 @@ +#!/bin/sh +echo "Updating prefs" +python pref_gen.py prefs2.conf +python ../../../cmake/admSerialization.py prefs2.conf + diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/CMakeLists.txt avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/CMakeLists.txt --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/CMakeLists.txt 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/CMakeLists.txt 2014-03-12 06:15:23.000000000 +0000 @@ -8,4 +8,5 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ADM_coreLibVA/include) TARGET_LINK_LIBRARIES(ADM_coreLibVA6 va va-x11) TARGET_LINK_LIBRARIES(ADM_coreLibVA6 ADM_core6 ADM_coreUI6 ADM_coreImage6) +TARGET_LINK_LIBRARIES(ADM_coreLibVA6 "c") ADM_INSTALL_LIB(ADM_coreLibVA6) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreVideoCodec/include/ADM_ffmp43.h avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreVideoCodec/include/ADM_ffmp43.h --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreVideoCodec/include/ADM_ffmp43.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreVideoCodec/include/ADM_ffmp43.h 2014-03-12 06:15:23.000000000 +0000 @@ -40,6 +40,7 @@ int codecId; uint8_t _refCopy; AVCodecContext *_context; + uint8_t *_extraDataCopy; AVFrame _frame; uint8_t _allowNull; uint32_t frameType (void); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreVideoCodec/src/ADM_codecFFsimple.cpp avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreVideoCodec/src/ADM_codecFFsimple.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreVideoCodec/src/ADM_codecFFsimple.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreVideoCodec/src/ADM_codecFFsimple.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -30,16 +30,9 @@ ADM_assert(c); CodecID id=c->codecId; ADM_assert(id!=CODEC_ID_NONE); - uint8_t *extraCopy=NULL; - if(extraDataLen) - { - extraCopy=(uint8_t *)malloc(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - } if(true==c->extraData) { - _context->extradata = (uint8_t *) extraCopy; + _context->extradata = (uint8_t *) _extraDataCopy; _context->extradata_size = (int) extraDataLen; } if(true==c->refCopy) @@ -68,7 +61,7 @@ { printf("[lavc] Decoder init: %x video decoder initialized! (%s)\n",fcc,codec->long_name); } - if(extraCopy) free(extraCopy); + } /** \fn admCreateFFSimple diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreVideoCodec/src/ADM_ffmp43.cpp avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreVideoCodec/src/ADM_ffmp43.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_core/ADM_coreVideoCodec/src/ADM_ffmp43.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/ADM_coreVideoCodec/src/ADM_ffmp43.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -213,6 +213,15 @@ printf ("[lavc] Build: %d\n", LIBAVCODEC_BUILD); _context->debug_mv |= FF_SHOW; _context->debug |= FF_DEBUG_VIS_MB_TYPE + FF_DEBUG_VIS_QP; + _extraDataCopy=NULL; + + if(extraDataLen) + { + _extraDataCopy=new uint8_t[extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE]; + memset(_extraDataCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); + memcpy(_extraDataCopy,extraData,extraDataLen); + } + } @@ -236,6 +245,11 @@ _context=NULL; printf ("[lavc] Destroyed\n"); } + if(_extraDataCopy) + { + delete [] _extraDataCopy; + _extraDataCopy=NULL; + } } /** @@ -525,21 +539,16 @@ ADM_info ("[lavc] Using %d bytes of extradata for MPEG4 decoder\n", (int)extraDataLen); _refCopy = 1; // YUV420 only - uint8_t *extraCopy=NULL; - if(extraDataLen) - { - extraCopy=(uint8_t *)malloc(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - } - _context->extradata = extraCopy; + + + _context->extradata = _extraDataCopy; _context->extradata_size = (int)extraDataLen ; _context->codec_tag=fcc; _context->stream_codec_tag=fcc; decoderMultiThread (); // _context->flags|=FF_DEBUG_VIS_MV; WRAP_Open (CODEC_ID_MPEG4); - if(extraCopy) free(extraCopy); + } bool decoderFFMpeg4::uncompress (ADMCompressedImage * in, ADMImage * out) { @@ -556,17 +565,12 @@ decoderFFDV::decoderFFDV (uint32_t w, uint32_t h,uint32_t fcc, uint32_t extraDataLen, uint8_t *extraData,uint32_t bpp): decoderFF (w, h,fcc,extraDataLen,extraData,bpp) { - uint8_t *extraCopy=NULL; - if(extraDataLen) - { - extraCopy=(uint8_t *)malloc(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - } - _context->extradata = extraCopy; + + + _context->extradata = _extraDataCopy; _context->extradata_size = (int)extraDataLen ; WRAP_Open (CODEC_ID_DVVIDEO); - if(extraCopy) free(extraCopy); + } decoderFFMpeg12::decoderFFMpeg12 (uint32_t w, uint32_t h,uint32_t fcc, uint32_t extraDataLen, uint8_t *extraData,uint32_t bpp): @@ -585,38 +589,27 @@ decoderFF_ffhuff::decoderFF_ffhuff (uint32_t w, uint32_t h,uint32_t fcc, uint32_t extraDataLen, uint8_t *extraData,uint32_t bpp) :decoderFF (w, h,fcc,extraDataLen,extraData,bpp) { - uint8_t *extraCopy=NULL; - if(extraDataLen) - { - extraCopy=(uint8_t *)malloc(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - } - _context->extradata = extraCopy; + + + _context->extradata = _extraDataCopy; _context->extradata_size = (int)extraDataLen ; _context->bits_per_coded_sample=bpp; ADM_info ("[lavc] FFhuff: We have %d bytes of extra data\n", (int)extraDataLen); WRAP_Open (CODEC_ID_FFVHUFF); - if(extraCopy) free(extraCopy); + } decoderFFH264::decoderFFH264 (uint32_t w, uint32_t h,uint32_t fcc, uint32_t extraDataLen, uint8_t *extraData,uint32_t bpp) :decoderFF (w, h,fcc,extraDataLen,extraData,bpp) { - uint8_t *extraCopy=NULL; - if(extraDataLen) - { - extraCopy=(uint8_t *)malloc(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - } - _context->extradata = extraCopy; + + _context->extradata = _extraDataCopy; _refCopy = 1; // YUV420 only _context->extradata_size = (int) extraDataLen; decoderMultiThread (); ADM_info ("[lavc] Initializing H264 decoder with %d extradata\n", (int)extraDataLen); WRAP_Open(CODEC_ID_H264); - if(extraCopy) free(extraCopy); + } //********************* extern "C" {int av_getAVCStreamInfo(AVCodecContext *avctx, uint32_t *nalSize, uint32_t *isAvc);} @@ -644,18 +637,12 @@ decoderFFhuff::decoderFFhuff (uint32_t w, uint32_t h,uint32_t fcc, uint32_t extraDataLen, uint8_t *extraData,uint32_t bpp): decoderFF (w, h,fcc,extraDataLen,extraData,bpp) { - uint8_t *extraCopy=NULL; - if(extraDataLen) - { - extraCopy=(uint8_t *)malloc(extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memset(extraCopy,0,extraDataLen+FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(extraCopy,extraData,extraDataLen); - } - _context->extradata = extraCopy; + + _context->extradata = _extraDataCopy; _context->extradata_size = (int) extraDataLen; _context->bits_per_coded_sample = bpp; WRAP_Open (CODEC_ID_HUFFYUV); - if(extraCopy) free(extraCopy); + } //*************** diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_core/CMakeLists.txt avidemux2.6-2.6.8~ppa1/avidemux_core/CMakeLists.txt --- avidemux2.6-2.6.7~ppa3/avidemux_core/CMakeLists.txt 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_core/CMakeLists.txt 2014-03-12 06:15:23.000000000 +0000 @@ -99,6 +99,7 @@ ADD_SUBDIRECTORY(ADM_coreSocket) add_subdirectory(ADM_coreImageLoader) add_subdirectory(ADM_coreScript) +add_subdirectory(ADM_coreSubtitles) ######################################## # Config Summary diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_audioEncoders/aften/audioencoder_aften.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_audioEncoders/aften/audioencoder_aften.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_audioEncoders/aften/audioencoder_aften.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_audioEncoders/aften/audioencoder_aften.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -234,7 +234,8 @@ BITRATE(160), BITRATE(192), BITRATE(224), - BITRATE(384) + BITRATE(384), + BITRATE(448) }; diaElemMenu bitrate(&(config.bitrate), QT_TRANSLATE_NOOP("aften","_Bitrate:"), SZT(bitrateM),bitrateM); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_audioEncoders/faac/audioencoder_faac.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_audioEncoders/faac/audioencoder_faac.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_audioEncoders/faac/audioencoder_faac.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_audioEncoders/faac/audioencoder_faac.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -68,7 +68,9 @@ _globalHeader=globalHeader; switch(channels) { - case 1:outputChannelMapping[1] = ADM_CH_FRONT_LEFT;break; + case 1: + outputChannelMapping[0] = ADM_CH_MONO; + break; case 2: outputChannelMapping[0] = ADM_CH_FRONT_LEFT; outputChannelMapping[1] = ADM_CH_FRONT_RIGHT; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_audioEncoders/lavcodec/audioencoder_lavcodec.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_audioEncoders/lavcodec/audioencoder_lavcodec.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_audioEncoders/lavcodec/audioencoder_lavcodec.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_audioEncoders/lavcodec/audioencoder_lavcodec.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -186,9 +186,14 @@ CONTEXT->sample_fmt = AV_SAMPLE_FMT_FLTP; ret = avcodec_open2(CONTEXT, codec,NULL); if (ret<0) - { - printError("Init failed",ret); - return 0; + { + CONTEXT->sample_fmt=AV_SAMPLE_FMT_S16; + ret = avcodec_open2(CONTEXT, codec,NULL); + if (ret<0) + { + printError("Init failed",ret); + return 0; + } } //ADM_info("Frame size : %d, %d\n",CONTEXT->frame_size,_chunk/wavheader.channels); @@ -265,13 +270,23 @@ CHANNEL_TYPE *f=_incoming->getChannelMapping(); CHANNEL_TYPE *o=channelMapping; - // reorder and de-interleave - reorderToPlanar(&(tmpbuffer[tmphead]),planarBuffer,nbBlocks,f,o); - - int er=avcodec_fill_audio_frame(_frame, channel, + + int er; + if( CONTEXT->sample_fmt == AV_SAMPLE_FMT_FLTP) + { + // reorder and de-interleave + reorderToPlanar(&(tmpbuffer[tmphead]),planarBuffer,nbBlocks,f,o); + er=avcodec_fill_audio_frame(_frame, channel, AV_SAMPLE_FMT_FLTP, (uint8_t *)planarBuffer, count*sizeof(float), 0); + }else + { + dither16(&(tmpbuffer[tmphead]),count,channel); + er=avcodec_fill_audio_frame(_frame, channel, + AV_SAMPLE_FMT_S16, (uint8_t *)&(tmpbuffer[tmphead]), + count*sizeof(uint16_t), 0); + } if(er<0) { printError("Fill audio",er); @@ -345,10 +360,23 @@ int nbBlocks=count/channel; _frame->nb_samples=nbBlocks; - float *in=i2p(count); - int er=avcodec_fill_audio_frame(_frame, channel, + + + int er; + if( CONTEXT->sample_fmt == AV_SAMPLE_FMT_FLTP) + { + float *in=i2p(count); + // reorder and de-interleave + er=avcodec_fill_audio_frame(_frame, channel, AV_SAMPLE_FMT_FLTP, (uint8_t *)in, count*sizeof(float), 0); + }else + { // s16 + dither16(&(tmpbuffer[tmphead]),count,channel); + er=avcodec_fill_audio_frame(_frame, channel, + AV_SAMPLE_FMT_S16, (uint8_t *)&(tmpbuffer[tmphead]), + count*sizeof(uint16_t), 0); + } if(er<0) { printError("Fill audio",er); @@ -490,7 +518,8 @@ BITRATE(160), BITRATE(192), BITRATE(224), - BITRATE(384) + BITRATE(384), + BITRATE(448) }; diaElemMenu bitrate(&(config.bitrate), QT_TR_NOOP("_Bitrate:"), SZT(bitrateM),bitrateM); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvEntries.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvEntries.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvEntries.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvEntries.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -194,7 +194,7 @@ } - _mainaviheader.dwMicroSecPerFrame=(uint32_t)floor(50);; + _mainaviheader.dwMicroSecPerFrame=(uint32_t)floor(50.0F);; _videostream.fccType=fourCC::get((uint8_t *)"vids"); _video_bih.biBitCount=24; _videostream.dwInitialFrames= 0; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvIndexer.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvIndexer.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvIndexer.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvIndexer.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -151,7 +151,26 @@ parser->seek(tail); return 1; } - +/** + * + * @return + */ +static int mkvFindStartCode(uint8_t *& start, uint8_t *end) +{ + uint32_t last=0xffffffff; + while(startindex.size()) ix.Dts=ADM_NO_PTS; + }else if(isMpeg12Compatible(_videostream.fccHandler)) + { + + if(rpt) + memcpy(readBuffer,_tracks[0].headerRepeat,rpt); + parser->readBin(readBuffer+rpt,size-3); + uint8_t *begin=readBuffer; + uint8_t *end=readBuffer+size-3+rpt; + uint32_t flags=0; + while(begin>3; + begin+=4; + picType&=7; + switch(picType) + { + case 1: ix.flags=AVI_KEY_FRAME;break; + case 2: ix.flags=AVI_P_FRAME;break; + case 4: ix.flags=AVI_P_FRAME;break; + case 3: ix.flags=AVI_B_FRAME;break; + default: ADM_warning("[Mpeg2inMkv]Bad pictype : %d\n",picType); + } + break; + } + + } + } } Track->index.append(ix); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsBruteForce.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsBruteForce.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsBruteForce.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsBruteForce.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -21,6 +21,7 @@ #include "ADM_tsPatPmt.h" #include "ADM_a52info.h" +#include "ADM_eac3info.h" #include "ADM_mp3info.h" #include "ADM_coreUtils.h" @@ -258,7 +259,23 @@ uint32_t fq,br,chan,syncoff; uint32_t fq2,br2,chan2,syncoff2; - // Is it AC3 ?? No false positive with A52/AC3.. + // Is it EAC3 ?? + ADM_EAC3_INFO eac3,eac32; + if(ADM_EAC3GetInfo(ptr, len, &syncoff,&eac3)) + { + ADM_info("Maybe EAC3... \n"); + // Try on 2nd packet... + if(ADM_EAC3GetInfo(ptr2, len2, &syncoff,&eac32)) + { + if((eac3.frequency==eac32.frequency) && (eac3.byterate==eac32.byterate) && (eac3.channels==eac32.channels)) + { + ADM_warning("\tProbably EAC3 : Fq=%d br=%d chan=%d\n",(int)eac3.frequency,(int)eac3.byterate,(int)eac3.channels); + trackType=ADM_TS_EAC3; + return true; + } + } + } + // AC3 maybe ? if( ADM_AC3GetInfo(ptr,len, &fq, &br, &chan,&syncoff)) { ADM_info("Maybe AC3... \n"); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsIndex.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsIndex.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsIndex.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsIndex.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -110,6 +110,7 @@ index=NULL; pkt=NULL; audioTracks=NULL; + beginConsuming=0; ui=createWorking ("Indexing"); audioTracks=trk; ticktock.reset(); @@ -285,7 +286,8 @@ qfprintf(index," %c%c",Type[picUnit->imageType],Structure[pictStruct&3]); - qfprintf(index,":%06"PRIx32,nextConsumed-beginConsuming); + int32_t delta=(int32_t)(nextConsumed-beginConsuming); + qfprintf(index,":%06"PRIx32,delta); qfprintf(index,":%"PRId64":%"PRId64,deltaPts,deltaDts); beginConsuming=nextConsumed; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/MpegTS/dmxTSPacket.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/MpegTS/dmxTSPacket.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/MpegTS/dmxTSPacket.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/MpegTS/dmxTSPacket.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -590,6 +590,7 @@ oldStartAt=0xfffffff; oldBufferLen=0; pesPacket=new TS_PESpacket(pid); + consumed=0; eof=false; } /** diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/OpenDml/ADM_odml_audio.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/OpenDml/ADM_odml_audio.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_demuxers/OpenDml/ADM_odml_audio.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_demuxers/OpenDml/ADM_odml_audio.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -49,18 +49,20 @@ this->extraDataLen=extraLen; length=0; uint32_t mx=0; + bool doSplit=false; for(int i=0;imx) mx=idx[i].size; } - + int bytePerSample=2; + int maxAllowed=ODML_MAX_AUDIO_CHUNK; if((hdr->encoding==WAV_PCM || hdr->encoding==WAV_LPCM)) { // Number of samples in one chunk - int maxAllowed=ODML_MAX_AUDIO_CHUNK; - int bytePerSample=2; + + if(hdr->bitspersample==8) bytePerSample=1; int thirtyMs=(bytePerSample*hdr->channels*hdr->frequency)/40; // ~ 25 ms if(thirtyMsmaxAllowed) { + doSplit=true; + } + } + if(doSplit) + { ADM_info("Splitting it...\n"); // Split the huge chunk into smaller ones audioClock clock(hdr->frequency); @@ -101,12 +108,11 @@ myIndex.append(current); clock.advanceBySample(size/(bytePerSample*hdr->channels)); } - } - }else { // Duplicate index as is for(int i=0;igetVar(key); + if(!src) src=""; + } + } + return strdup(src); } + // EOF diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/ADM_pyAvidemux.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/ADM_pyAvidemux.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/ADM_pyAvidemux.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/ADM_pyAvidemux.h 2014-03-12 06:15:23.000000000 +0000 @@ -68,6 +68,8 @@ /* Misc */ int pyTestCrash(void); int pyTestAssert(void); - +int pyTestSub( char *subName); +/* OS */ +char *pyGetEnv(IEditor *editor,const char *); #endif // EOF diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/ADM_pyTests.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/ADM_pyTests.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/ADM_pyTests.cpp 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/ADM_pyTests.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,69 @@ +/*************************************************************************** + \file ADM_pyAvidemux.cpp + \brief binding between tinyPy and avidemux + \author mean/gruntster 2011/2012 + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "ADM_pyAvidemux.h" +#include "ADM_audiodef.h" +#include "ADM_vidMisc.h" +#include "fourcc.h" +#include "DIA_fileSel.h" +#include "DIA_coreToolkit.h" +#include "ADM_coreSubtitles.h" + +/** + \fn pyTestCrash +*/ + +int pyTestCrash(void) +{ + int *foobar = NULL; + *foobar = 0; // CRASH! + return true; +} +/** + \fn pyTestAssert +*/ + +int pyTestAssert(void) +{ + ADM_assert(0); + return true; +} +int pyTestSub( char *subName) +{ + ADM_info("pyTestSub : %s\n",subName); + ADM_subtitle sub; + if(!sub.load(subName)) + { + ADM_warning("Cannot load <%s>\n",subName); + return -1; + } + ADM_info("Dumping : %s\n",subName); + sub.dump(); + + ADM_info("Converting to ssa: %s\n",subName); + sub.srt2ssa(); + + ADM_info("Dumping : %s\n",subName); + sub.dump(); + + ADM_info("Saving : %s\n",subName); + sub.saveAsSSA("/tmp/foo.ass"); + + + ADM_info("Done : %s\n",subName); + return 1; +} + +// EOF diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/binding/pyHelpers.admPyFunc avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/binding/pyHelpers.admPyFunc --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/binding/pyHelpers.admPyFunc 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/binding/pyHelpers.admPyFunc 2014-03-12 06:15:23.000000000 +0000 @@ -1,4 +1,4 @@ # Basic action load, handle seg, getInfo -/* FUNC */ int pyTestAssert:testAssert (void ) +/* FUNC */ int pyTestAssert:testAssert (void ) /* FUNC */ int pyTestCrash:testCrash (void ) - +/* FUNC */ int pyTestSub:testSub (char) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/CMakeLists.txt avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/CMakeLists.txt --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/CMakeLists.txt 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/CMakeLists.txt 2014-03-12 06:15:23.000000000 +0000 @@ -6,6 +6,7 @@ PythonScriptWriter.cpp TinyParams.cpp ADM_script_tinyPy.v + ADM_pyTests.cpp modules/re/init.cpp ) @@ -20,8 +21,9 @@ include_directories(../../ADM_coreScript/include) include_directories(${AVIDEMUX_TOP_SOURCE_DIR}/avidemux/common) include_directories(${AVIDEMUX_TOP_SOURCE_DIR}/avidemux/common/ADM_editor/include) +include_directories(${AVIDEMUX_TOP_SOURCE_DIR}/avidemux_core/ADM_coreSubtitles/inc) -target_link_libraries(ADM_script_tinyPy ADM_coreScript ADM_coreUtils6 ADM_core6 ADM_coreUI6 m) +target_link_libraries(ADM_script_tinyPy ADM_coreScript ADM_coreUtils6 ADM_core6 ADM_coreUI6 ADM_coreSubtitle m) if (NOT APPLE) target_link_libraries(ADM_script_tinyPy -Wl,--version-script,"${CMAKE_CURRENT_SOURCE_DIR}/ADM_script_tinyPy.v") diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/pyHelpers_gen.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/pyHelpers_gen.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/pyHelpers_gen.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/pyHelpers_gen.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -10,8 +10,16 @@ int r=pyTestCrash(); return tp_number(r); } +//int pyTestSub +tp_obj zzpy_testSub(TP) +{ +char * p0=(char *)TP_STR().string.val; +int r=pyTestSub(p0); +return tp_number(r); +} pyFunc pyHelpers_functions[]={ {"testAssert",zzpy_testAssert}, {"testCrash",zzpy_testCrash}, +{"testSub",zzpy_testSub}, {NULL,NULL} }; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/PythonEngine.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/PythonEngine.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/PythonEngine.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/PythonEngine.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -31,6 +31,7 @@ #define ADM_PYID_AVIDEMUX 100 #define ADM_PYID_EDITOR 101 #define ADM_PYID_GUI 102 +#define ADM_PYID_OS 103 #define ADM_PYID_DIALOGF 200 #define ADM_PYID_DF_TOGGLE 201 #define ADM_PYID_DF_INTEGER 202 @@ -129,8 +130,14 @@ {"basename", PythonEngine::basename}, {"dirname", PythonEngine::dirname}, {NULL, NULL}}; + + pyFunc osStaticClassFunctions[] = {{"environ", PythonEngine::pyenviron}, + {NULL, NULL}}; + + re_init(_vm); this->registerFunction("addons", addonFunctions); + this->registerClass("Avidemux", initClasspyAdm, "avidemux class"); this->registerClass("Editor", initClasspyEditor, "add, remove videos"); this->registerClass("Gui", initClasspyGui, "widget, alert boxes,.."); @@ -140,6 +147,7 @@ this->registerClass("DFTimeStamp", initClasspyDFTimeStamp, "UI element : timestamp"); this->registerClass("DialogFactory", initClasspyDialogFactory, "UI manager, handle all UI elements"); this->registerFunction("test", pyHelpers_functions); + this->registerStaticClass("os",osStaticClassFunctions,"Access to operating system"); } void PythonEngine::registerClass(const char *className, pyRegisterClass classPy, const char *desc) @@ -154,7 +162,42 @@ tp_set(_vm, _vm->builtins, tp_string(className), classPy(_vm)); } +/** + * + * @param vm + * @return + */ +static tp_obj myCtorpyStatic(tp_vm *vm) +{ + return tp_None; +} +/** + * \fn registerStaticClass + */ +void PythonEngine::registerStaticClass(const char *thisClass,pyFunc *funcs,const char *desc) +{ + this->callEventHandlers(IScriptEngine::Information, NULL, -1, + (string("Registering static class ") + string(thisClass)).c_str()); + + tp_obj classObj = tp_dict(_vm); + + pyClassDescriptor classDesc; + classDesc.className = string(thisClass); + classDesc.desc = string(desc); + _pyClasses.push_back(classDesc); + + while (funcs->funcName) + { + this->callEventHandlers(IScriptEngine::Information, NULL, -1, + (string("\tRegistering: ") + string(funcs->funcName)).c_str()); + + tp_set(_vm, classObj, tp_string(funcs->funcName), tp_fnc(_vm, funcs->funcCall)); + funcs++; + } + tp_set(_vm, _vm->modules, tp_string(thisClass), classObj); + +} void PythonEngine::registerFunction(const char *group, pyFunc *funcs) { this->callEventHandlers(IScriptEngine::Information, NULL, -1, @@ -163,7 +206,7 @@ while (funcs->funcName) { this->callEventHandlers(IScriptEngine::Information, NULL, -1, - (string("Registering: ") + string(funcs->funcName)).c_str()); + (string("\tRegistering: ") + string(funcs->funcName)).c_str()); tp_set(_vm, _vm->builtins, tp_string(funcs->funcName), tp_fnc(_vm, funcs->funcCall)); @@ -368,3 +411,23 @@ { return ""; } +/** + * \fn environ + * \brief os.environ + * @param tp + * @return + */ +tp_obj PythonEngine::pyenviron(tp_vm *tp) +{ + TinyParams pm(tp); + const char *file = pm.asString(); + const char *defaultRet=""; + char *output=NULL; + PythonEngine *engine = (PythonEngine*)tp_get(tp, tp->builtins, tp_string("userdata")).data.val; + + + output=pyGetEnv(engine->editor(),file); + if(output) defaultRet=output; + tp_obj v = tp_string_copy(tp,defaultRet,strlen(defaultRet)); + return v; +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/update.make avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/update.make --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_scriptEngines/tinyPy/src/update.make 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_scriptEngines/tinyPy/src/update.make 2014-03-12 06:15:23.000000000 +0000 @@ -1,5 +1,5 @@ OBJS1=pyHelpers_gen.cpp -OBJS=adm_gen.cpp editor_gen.cpp pyDFInteger_gen.cpp pyDFToggle_gen.cpp pyDialogFactory_gen.cpp pyDFMenu_gen.cpp pyDFTimeStamp_gen.cpp GUI_gen.cpp +OBJS=adm_gen.cpp editor_gen.cpp pyDFInteger_gen.cpp pyDFToggle_gen.cpp pyDialogFactory_gen.cpp pyDFMenu_gen.cpp pyDFTimeStamp_gen.cpp GUI_gen.cpp %_gen.cpp:binding/%.admPyClass perl ../../../../cmake/admPyClass.pl $< $@ diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/ADM_x264.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/ADM_x264.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/ADM_x264.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/ADM_x264.h 2014-03-12 06:15:23.000000000 +0000 @@ -27,6 +27,7 @@ #define X264_DEFAULT_CONF \ { \ + true, /* bool UseAdvancedConfiguration */ \ { /* General */ \ { \ COMPRESS_AQ, /* COMPRESSION_MODE mode */ \ @@ -43,6 +44,11 @@ 0*ADM_ENC_CAP_SAME \ }, \ 99, /* Threads : auto */ \ + NULL, /* Preset */ \ + NULL, /* Tuning */ \ + NULL, /* Profile */ \ + false, /* Fast decode */ \ + false, /* Zero latency */ \ true /* Fast first pass */ \ }, \ -1, /* Level */ \ diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/ADM_x264Setup.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/ADM_x264Setup.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/ADM_x264Setup.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/ADM_x264Setup.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -52,11 +52,30 @@ { ADM_info("=============x264, setting up==============\n"); MMSET(param); + x264_param_default( ¶m); param.pf_log=logger; firstIdr=true; image=new ADMImageDefault(getWidth(),getHeight()); + // -------------- preset, tune, idc ------------ + if(!x264Settings.useAdvancedConfiguration) + { + char tune[200] = {0}; + strcat(tune, x264Settings.general.tuning); + if(x264Settings.general.fast_decode) + { + strcat(tune, ","); + strcat(tune, "fastdecode"); + } + if(x264Settings.general.zero_latency) + { + strcat(tune, ","); + strcat(tune, "zero_latency"); + } + x264_param_default_preset(¶m, x264Settings.general.preset, tune); + } + param.i_level_idc=x264Settings.level; // Threads.. switch(x264Settings.general.threads) @@ -69,118 +88,25 @@ param.i_height = getHeight(); param.i_csp = X264_CSP_I420; param.i_log_level=X264_LOG_INFO; //DEBUG; //INFO; - param.i_level_idc=x264Settings.level; - //Framerate - int n,d; - uint64_t f=source->getInfo()->frameIncrement; - usSecondsToFrac(f,&n,&d); - param.i_fps_num = d; - param.i_fps_den = n; - if(!x264Settings.MaxBFrame) encoderDelay=0; - else - { - if(2>=x264Settings.MaxRefFrames) - { - encoderDelay=f*2*2; - } - else - { - encoderDelay=2*f*(x264Settings.MaxRefFrames-1); - } - } -#define MKPARAM(x,y) {param.x = x264Settings.y;aprintf("[x264] "#x" = %d\n",param.x);} -#define MKPARAMF(x,y) {param.x = (float)x264Settings.y; aprintf("[x264] "#x" = %.2f\n",param.x);} -#define MKPARAMB(x,y) {param.x = x264Settings.y ;aprintf("[x264] "#x" = %s\n",TrueFalse[param.x&1]);} - MKPARAM(i_frame_reference,MaxRefFrames); - MKPARAM(i_keyint_min,MinIdr); - MKPARAM(i_keyint_max,MaxIdr); - MKPARAM(i_scenecut_threshold,i_scenecut_threshold); - MKPARAMB(b_intra_refresh,intra_refresh); - MKPARAM(i_bframe,MaxBFrame); - - MKPARAM(i_bframe_adaptive,i_bframe_adaptive); - MKPARAM(i_bframe_bias,i_bframe_bias); - MKPARAM(i_bframe_pyramid,i_bframe_pyramid); - MKPARAMB(b_deblocking_filter,b_deblocking_filter); - if(param.b_deblocking_filter) - { - MKPARAM(i_deblocking_filter_alphac0,i_deblocking_filter_alphac0); - MKPARAM(i_deblocking_filter_beta,i_deblocking_filter_beta); - } - MKPARAMB(b_cabac,cabac); - MKPARAMB(b_interlaced,interlaced); - MKPARAMB(b_constrained_intra,constrained_intra); - MKPARAMB(b_tff,tff); - MKPARAMB(b_fake_interlaced,fake_interlaced); + + //Framerate + int n,d; + uint64_t f=source->getInfo()->frameIncrement; + usSecondsToFrac(f,&n,&d); + param.i_fps_num = d; + param.i_fps_den = n; // -------------- vui------------ -#undef MKPARAM -#undef MKPARAMF -#undef MKPARAMB -#define MKPARAM(x,y) {param.vui.x = x264Settings.vui.y;aprintf("[x264] vui."#x" = %d\n",param.vui.x);} -#define MKPARAMF(x,y) {param.vui.x = (float)x264Settings.vui.y; aprintf("[x264] vui."#x" = %.2f\n",param.vui.x);} -#define MKPARAMB(x,y) {param.vui.x = x264Settings.vui.y ;aprintf("[x264] vui."#x" = %s\n",TrueFalse[param.vui.x&1]);} - MKPARAM (i_sar_width,sar_width) - MKPARAM (i_sar_height,sar_height) - - // -------------- analyze------------ -#undef MKPARAM -#undef MKPARAMF -#undef MKPARAMB -#define MKPARAM(x,y) {param.analyse.x = x264Settings.analyze.y;aprintf("[x264] analyse."#x" = %d\n",param.analyse.x);} -#define MKPARAMF(x,y) {param.analyse.x = (float)x264Settings.analyze.y; aprintf("[x264] analyse."#x" = %.2f\n",param.analyse.x);} -#define MKPARAMB(x,y) {param.analyse.x = x264Settings.analyze.y ;aprintf("[x264] analyse."#x" = %s\n",TrueFalse[param.analyse.x&1]);} -#define MKFLAGS(fieldout,fieldin,mask) {if(x264Settings.analyze.fieldin) param.analyse.fieldout|=mask;} - MKPARAMB(b_transform_8x8,b_8x8) - MKPARAMB(b_weighted_bipred,weighted_bipred) - MKPARAM (i_weighted_pred,weighted_pred) - MKPARAM (i_direct_mv_pred,direct_mv_pred) - MKPARAM (i_chroma_qp_offset,chroma_offset) - - MKPARAM (i_me_method,me_method) - MKPARAM (i_me_range,me_range) - MKPARAM (i_mv_range,mv_range) - MKPARAM (i_mv_range_thread,mv_range_thread) - MKPARAM (i_subpel_refine,subpel_refine) - MKPARAMB(b_chroma_me,chroma_me) - MKPARAMB(b_mixed_references,mixed_references) - MKPARAM (i_trellis,trellis) - MKPARAMB(b_fast_pskip,fast_pskip) - MKPARAMB(b_dct_decimate,dct_decimate) - MKPARAMB(b_psy,psy) - MKPARAMF(f_psy_rd,psy_rd) - MKPARAMF(f_psy_trellis,psy_trellis) - MKPARAM (i_noise_reduction,noise_reduction) - MKPARAM (i_luma_deadzone[0],inter_luma) - MKPARAM (i_luma_deadzone[1],intra_luma) - - MKFLAGS(inter,b_i4x4,X264_ANALYSE_I4x4) - MKFLAGS(inter,b_i8x8,X264_ANALYSE_I8x8) - MKFLAGS(inter,b_p16x16,X264_ANALYSE_PSUB16x16) - MKFLAGS(inter,b_p8x8,X264_ANALYSE_PSUB8x8) - MKFLAGS(inter,b_b16x16,X264_ANALYSE_BSUB16x16) - - //---------------- ratecontrol ------------------- -#undef MKPARAM -#undef MKPARAMF -#undef MKPARAMB -#define MKPARAM(x,y) {param.rc.x = x264Settings.ratecontrol.y;aprintf("[x264] rc."#x" = %d\n",param.rc.x);} -#define MKPARAMF(x,y) {param.rc.x = (float)x264Settings.ratecontrol.y; aprintf("[x264] rc."#x" = %.2f\n",param.rc.x);} -#define MKPARAMB(x,y) {param.rc.x = x264Settings.ratecontrol.y ;aprintf("[x264] rc."#x" = %s\n",TrueFalse[param.rc.x&1]);} - - MKPARAM(i_qp_min,qp_min); - MKPARAM(i_qp_max,qp_max); - MKPARAM(i_qp_step,qp_step); - MKPARAM(f_rate_tolerance,rate_tolerance); - MKPARAM(f_ip_factor,ip_factor); - MKPARAM(f_pb_factor,pb_factor); - MKPARAMB(b_mb_tree,mb_tree); - MKPARAM(i_lookahead,lookahead); - MKPARAM(i_aq_mode,aq_mode); - MKPARAMF(f_aq_strength,aq_strength); - // ------------------------- - + #undef MKPARAM + #undef MKPARAMF + #undef MKPARAMB + #define MKPARAM(x,y) {param.vui.x = x264Settings.vui.y;aprintf("[x264] vui."#x" = %d\n",param.vui.x);} + #define MKPARAMF(x,y) {param.vui.x = (float)x264Settings.vui.y; aprintf("[x264] vui."#x" = %.2f\n",param.vui.x);} + #define MKPARAMB(x,y) {param.vui.x = x264Settings.vui.y ;aprintf("[x264] vui."#x" = %s\n",TrueFalse[param.vui.x&1]);} + MKPARAM (i_sar_width,sar_width) + MKPARAM (i_sar_height,sar_height) + // -------------- rate control------------ switch(x264Settings.general.params.mode) { case COMPRESS_2PASS: @@ -220,7 +146,7 @@ #warning FIXME #if 0 if(x264Settings.) - x264_param_apply_fastfirstpass(&_param); + x264_param_apply_fastfirstpass(&_param); #endif }else @@ -262,6 +188,108 @@ // We do pseudo cfr ... param.b_vfr_input=0; + + if(x264Settings.useAdvancedConfiguration) + { + + #undef MKPARAM + #undef MKPARAMF + #undef MKPARAMB + #define MKPARAM(x,y) {param.x = x264Settings.y;aprintf("[x264] "#x" = %d\n",param.x);} + #define MKPARAMF(x,y) {param.x = (float)x264Settings.y; aprintf("[x264] "#x" = %.2f\n",param.x);} + #define MKPARAMB(x,y) {param.x = x264Settings.y ;aprintf("[x264] "#x" = %s\n",TrueFalse[param.x&1]);} + MKPARAM(i_frame_reference,MaxRefFrames); + MKPARAM(i_keyint_min,MinIdr); + MKPARAM(i_keyint_max,MaxIdr); + MKPARAM(i_scenecut_threshold,i_scenecut_threshold); + MKPARAMB(b_intra_refresh,intra_refresh); + MKPARAM(i_bframe,MaxBFrame); + + MKPARAM(i_bframe_adaptive,i_bframe_adaptive); + MKPARAM(i_bframe_bias,i_bframe_bias); + MKPARAM(i_bframe_pyramid,i_bframe_pyramid); + MKPARAMB(b_deblocking_filter,b_deblocking_filter); + if(param.b_deblocking_filter) + { + MKPARAM(i_deblocking_filter_alphac0,i_deblocking_filter_alphac0); + MKPARAM(i_deblocking_filter_beta,i_deblocking_filter_beta); + } + MKPARAMB(b_cabac,cabac); + MKPARAMB(b_interlaced,interlaced); + MKPARAMB(b_constrained_intra,constrained_intra); + MKPARAMB(b_tff,tff); + MKPARAMB(b_fake_interlaced,fake_interlaced); + + // -------------- analyze------------ + #undef MKPARAM + #undef MKPARAMF + #undef MKPARAMB + #define MKPARAM(x,y) {param.analyse.x = x264Settings.analyze.y;aprintf("[x264] analyse."#x" = %d\n",param.analyse.x);} + #define MKPARAMF(x,y) {param.analyse.x = (float)x264Settings.analyze.y; aprintf("[x264] analyse."#x" = %.2f\n",param.analyse.x);} + #define MKPARAMB(x,y) {param.analyse.x = x264Settings.analyze.y ;aprintf("[x264] analyse."#x" = %s\n",TrueFalse[param.analyse.x&1]);} + #define MKFLAGS(fieldout,fieldin,mask) {if(x264Settings.analyze.fieldin) param.analyse.fieldout|=mask;} + MKPARAMB(b_transform_8x8,b_8x8) + MKPARAMB(b_weighted_bipred,weighted_bipred) + MKPARAM (i_weighted_pred,weighted_pred) + MKPARAM (i_direct_mv_pred,direct_mv_pred) + MKPARAM (i_chroma_qp_offset,chroma_offset) + + MKPARAM (i_me_method,me_method) + MKPARAM (i_me_range,me_range) + MKPARAM (i_mv_range,mv_range) + MKPARAM (i_mv_range_thread,mv_range_thread) + MKPARAM (i_subpel_refine,subpel_refine) + MKPARAMB(b_chroma_me,chroma_me) + MKPARAMB(b_mixed_references,mixed_references) + MKPARAM (i_trellis,trellis) + MKPARAMB(b_fast_pskip,fast_pskip) + MKPARAMB(b_dct_decimate,dct_decimate) + MKPARAMB(b_psy,psy) + MKPARAMF(f_psy_rd,psy_rd) + MKPARAMF(f_psy_trellis,psy_trellis) + MKPARAM (i_noise_reduction,noise_reduction) + MKPARAM (i_luma_deadzone[0],inter_luma) + MKPARAM (i_luma_deadzone[1],intra_luma) + + MKFLAGS(inter,b_i4x4,X264_ANALYSE_I4x4) + MKFLAGS(inter,b_i8x8,X264_ANALYSE_I8x8) + MKFLAGS(inter,b_p16x16,X264_ANALYSE_PSUB16x16) + MKFLAGS(inter,b_p8x8,X264_ANALYSE_PSUB8x8) + MKFLAGS(inter,b_b16x16,X264_ANALYSE_BSUB16x16) + + //---------------- ratecontrol ------------------- + #undef MKPARAM + #undef MKPARAMF + #undef MKPARAMB + #define MKPARAM(x,y) {param.rc.x = x264Settings.ratecontrol.y;aprintf("[x264] rc."#x" = %d\n",param.rc.x);} + #define MKPARAMF(x,y) {param.rc.x = (float)x264Settings.ratecontrol.y; aprintf("[x264] rc."#x" = %.2f\n",param.rc.x);} + #define MKPARAMB(x,y) {param.rc.x = x264Settings.ratecontrol.y ;aprintf("[x264] rc."#x" = %s\n",TrueFalse[param.rc.x&1]);} + + MKPARAM(i_qp_min,qp_min); + MKPARAM(i_qp_max,qp_max); + MKPARAM(i_qp_step,qp_step); + MKPARAM(f_rate_tolerance,rate_tolerance); + MKPARAM(f_ip_factor,ip_factor); + MKPARAM(f_pb_factor,pb_factor); + MKPARAMB(b_mb_tree,mb_tree); + MKPARAM(i_lookahead,lookahead); + MKPARAM(i_aq_mode,aq_mode); + MKPARAMF(f_aq_strength,aq_strength); + } + + if(!param.i_bframe) encoderDelay=0; + else + { + if(2>=param.i_frame_reference) + { + encoderDelay=f*2*2; + } + else + { + encoderDelay=2*f*(x264Settings.MaxRefFrames-1); + } + } + // if(true==x264Settings.general.fast_first_pass) { @@ -279,6 +307,12 @@ } } } + + if(!x264Settings.useAdvancedConfiguration) + { + x264_param_apply_profile(¶m, x264Settings.general.profile); + } + dumpx264Setup(¶m); ADM_info("Creating x264 encoder\n"); handle = x264_encoder_open (¶m); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/CMakeLists.txt avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/CMakeLists.txt --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/CMakeLists.txt 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/CMakeLists.txt 2014-03-12 06:15:23.000000000 +0000 @@ -40,7 +40,7 @@ if(DO_SETTINGS) FILE(GLOB json_files ${CMAKE_CURRENT_SOURCE_DIR}/preset/*.json) message(STATUS "Presets found : ${json_files}") - INSTALL_VIDEO_ENCODER_SETTINGS(x264 VERSION 2 FILES ${json_files}) + INSTALL_VIDEO_ENCODER_SETTINGS(x264 VERSION 3 FILES ${json_files}) endif(DO_SETTINGS) ELSE(X264_FOUND) MESSAGE(STATUS "x264 disabled.") diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/fast.json avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/fast.json --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/fast.json 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/fast.json 2014-03-12 06:15:23.000000000 +0000 @@ -1,4 +1,5 @@ { + "useAdvancedConfiguration" : true, "general" : { "params" : "AQ=14", "threads" : 99, diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/iPhone.json avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/iPhone.json --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/iPhone.json 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/iPhone.json 2014-03-12 06:15:23.000000000 +0000 @@ -1,4 +1,5 @@ { + "useAdvancedConfiguration" : true, "general" : { "params" : "CBR=1000", "threads" : 99, diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/PSP.json avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/PSP.json --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/PSP.json 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/PSP.json 2014-03-12 06:15:23.000000000 +0000 @@ -1,4 +1,5 @@ { + "useAdvancedConfiguration" : true, "general" : { "params" : "CBR=1000", "threads" : 99, diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/ultraFast.json avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/ultraFast.json --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/ultraFast.json 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/ultraFast.json 2014-03-12 06:15:23.000000000 +0000 @@ -1,10 +1,11 @@ { + "useAdvancedConfiguration" : true, "general" : { "params" : "AQ=12", "threads" : 99, "fast_first_pass" : true }, - "level" : 4294967295, + "level" : -1, "vui" : { "sar_height" : 1, "sar_width" : 1 @@ -72,4 +73,4 @@ "mb_tree" : false, "lookahead" : 10 } -} \ No newline at end of file +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/veryFast.json avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/veryFast.json --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/preset/veryFast.json 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/preset/veryFast.json 2014-03-12 06:15:23.000000000 +0000 @@ -1,4 +1,5 @@ { + "useAdvancedConfiguration" : true, "general" : { "params" : "AQ=12", "threads" : 99, diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/qt4/Q_x264.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/qt4/Q_x264.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/qt4/Q_x264.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/qt4/Q_x264.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -21,7 +21,7 @@ #include "DIA_coreToolkit.h" #include "ADM_toolkitQt.h" -static int pluginVersion=2; +static int pluginVersion=3; static x264_encoder myCopy; // ugly... extern bool x264_encoder_jserialize(const char *file, const x264_encoder *key); @@ -57,6 +57,14 @@ }; #define NB_IDC sizeof(listOfIdc)/sizeof(idcToken) +static const idcToken listOfThreads[]={ + {0,"Auto"}, + {1,"1"}, + {2,"2"}, + {4,"4"}, +}; + +#define NB_THREADS sizeof(listOfThreads)/sizeof(idcToken) typedef struct { @@ -73,6 +81,16 @@ }; #define NB_SAR sizeof(predefinedARs)/sizeof(aspectRatio) + +static const char* listOfPresets[] = { "ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo" }; +#define NB_PRESET sizeof(listOfPresets)/sizeof(char*) + +static const char* listOfTunings[] = { "film", "animation", "grain", "stillimage", "psnr", "ssim" }; +#define NB_TUNE sizeof(listOfTunings)/sizeof(char*) + +static const char* listOfProfiles[] = { "baseline", "main", "high", "high10", "high422", "high444" }; +#define NB_PROFILE sizeof(listOfProfiles)/sizeof(char*) + /** \fn x264_ui \brief hook to enter UI specific dialog @@ -87,7 +105,16 @@ if (dialog.exec() == QDialog::Accepted) { dialog.download(); + if(settings->general.preset) ADM_dealloc(settings->general.preset); + settings->general.preset = NULL; + if(settings->general.tuning) ADM_dealloc(settings->general.tuning); + settings->general.tuning = NULL; + if(settings->general.profile) ADM_dealloc(settings->general.profile); + settings->general.profile = NULL; memcpy(settings,&myCopy,sizeof(myCopy)); + if(myCopy.general.preset) settings->general.preset = ADM_strdup(myCopy.general.preset); + if(myCopy.general.tuning) settings->general.tuning = ADM_strdup(myCopy.general.tuning); + if(myCopy.general.profile) settings->general.profile = ADM_strdup(myCopy.general.profile); success = true; } @@ -101,6 +128,7 @@ x264Dialog::x264Dialog(QWidget *parent, void *param) : QDialog(parent) { ui.setupUi(this); + connect(ui.useAdvancedConfigurationCheckBox, SIGNAL(toggled(bool)), this, SLOT(useAdvancedConfigurationCheckBox_toggled(bool))); connect(ui.encodingModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(encodingModeComboBox_currentIndexChanged(int))); connect(ui.quantiserSlider, SIGNAL(valueChanged(int)), this, SLOT(quantiserSlider_valueChanged(int))); connect(ui.meSlider, SIGNAL(valueChanged(int)), this, SLOT(meSlider_valueChanged(int))); @@ -114,7 +142,18 @@ connect(ui.maxCrfSlider, SIGNAL(valueChanged(int)), this, SLOT(maxCrfSlider_valueChanged(int))); connect(ui.maxCrfSpinBox, SIGNAL(valueChanged(int)), this, SLOT(maxCrfSpinBox_valueChanged(int))); #endif - memcpy(&myCopy,param,sizeof(myCopy)); + x264_encoder* settings = (x264_encoder*)param; + if(myCopy.general.preset) ADM_dealloc(myCopy.general.preset); + myCopy.general.preset = NULL; + if(myCopy.general.tuning) ADM_dealloc(myCopy.general.tuning); + myCopy.general.tuning = NULL; + if(myCopy.general.profile) ADM_dealloc(myCopy.general.profile); + myCopy.general.profile = NULL; + memcpy(&myCopy,settings,sizeof(myCopy)); + if(settings->general.preset) myCopy.general.preset = ADM_strdup(settings->general.preset); + if(settings->general.tuning) myCopy.general.tuning = ADM_strdup(settings->general.tuning); + if(settings->general.profile) myCopy.general.profile = ADM_strdup(settings->general.profile); + #define ENCODING(x) myCopy.general.params.x lastBitrate = ENCODING(bitrate); lastVideoSize = ENCODING(finalsize); @@ -133,6 +172,34 @@ idc->addItem(QString(t->idcString)); } + QComboBox *threads=ui.comboBoxThreads; + threads->clear(); + for(int i=0;iaddItem(QString(t->idcString)); + } + QComboBox* presets=ui.presetComboBox; + presets->clear(); + for(int i=0;iaddItem(QString(listOfPresets[i])); + } + + QComboBox* tunings=ui.tuningComboBox; + tunings->clear(); + for(int i=0;iaddItem(QString(listOfTunings[i])); + } + + QComboBox* profiles=ui.profileComboBox; + profiles->clear(); + for(int i=0;iaddItem(QString(listOfProfiles[i])); + } + upload(); ADM_pluginInstallSystem( std::string("x264"),std::string(".json"),pluginVersion); updatePresetList(); @@ -159,6 +226,22 @@ return true; } +bool x264Dialog::toogleAdvancedConfiguration(bool advancedEnabled) +{ + ui.useAdvancedConfigurationCheckBox->setChecked(advancedEnabled); + ui.presetComboBox->setEnabled(!advancedEnabled); + ui.tuningComboBox->setEnabled(!advancedEnabled); + ui.profileComboBox->setEnabled(!advancedEnabled); + ui.fastDecodeCheckBox->setEnabled(!advancedEnabled); + ui.zeroLatencyCheckBox->setEnabled(!advancedEnabled); + ui.tabAdvancedRC->setEnabled(advancedEnabled); + ui.tabMotion->setEnabled(advancedEnabled); + ui.tabPartition->setEnabled(advancedEnabled); + ui.tabFrame->setEnabled(advancedEnabled); + ui.tabAnalysis->setEnabled(advancedEnabled); + ui.tabQuantiser->setEnabled(advancedEnabled); +} + /** */ @@ -167,9 +250,23 @@ #define DISABLE(x) ui.x->setEnabled(false); #define MK_MENU(x,y) ui.x->setCurrentIndex(myCopy.y) #define MK_RADIOBUTTON(x) ui.x->setChecked(true); +#define MK_COMBOBOX_STR(x,y,list,count) \ + { \ + QComboBox *combobox=ui.x; \ + for(int i=0;isetCurrentIndex(i); \ + } \ + } \ + } bool x264Dialog::upload(void) { - + toogleAdvancedConfiguration(myCopy.useAdvancedConfiguration); + MK_CHECKBOX(fastDecodeCheckBox,general.fast_decode); + MK_CHECKBOX(zeroLatencyCheckBox,general.zero_latency); MK_CHECKBOX(fastFirstPassCheckBox,general.fast_first_pass); MK_CHECKBOX(fastPSkipCheckBox,analyze.fast_pskip); MK_CHECKBOX(weightedPredictCheckBox,analyze.weighted_bipred); @@ -264,6 +361,11 @@ MK_UINT(minThreadBufferSpinBox,analyze.mv_range_thread); } + // preset + MK_COMBOBOX_STR(presetComboBox, general.preset, listOfPresets, NB_PRESET); + MK_COMBOBOX_STR(profileComboBox, general.profile, listOfProfiles, NB_PROFILE); + MK_COMBOBOX_STR(tuningComboBox, general.tuning, listOfTunings, NB_TUNE); + // udate idc QComboBox *idc=ui.idcLevelComboBox; for(int i=0;iidcValue) + { + threads->setCurrentIndex(i); + break; + } + } switch(ENCODING(mode)) { case COMPRESS_AQ: // CRF @@ -330,9 +442,9 @@ DISABLE(spsiComboBox); DISABLE(openGopCheckBox); DISABLE(groupBox_14); // quant matrix - DISABLE(tab_7); - DISABLE(tab_9); - DISABLE(tab); + DISABLE(tabAdvanced1); + DISABLE(tabAdvanced2); + DISABLE(tabOutput2); DISABLE(maxCrfCheckBox); DISABLE(sarAsInputRadioButton); DISABLE(groupBox_3); @@ -343,12 +455,25 @@ #undef MK_UINT #undef MK_MENU #undef MK_RADIOBUTTON +#undef MK_COMBOBOX_STR #define MK_CHECKBOX(x,y) myCopy.y=ui.x->isChecked() #define MK_UINT(x,y) myCopy.y=ui.x->value() #define MK_MENU(x,y) myCopy.y=ui.x->currentIndex() #define MK_RADIOBUTTON(x,y) myCopy.y=ui.x->setChecked(true); +#define MK_COMBOBOX_STR(x,y,list,count) \ + { \ + QComboBox* combo=ui.x; \ + int idx=combo->currentIndex(); \ + ADM_assert(idxcurrentIndex(); ADM_assert(dexvalue();;break; case 4: ENCODING(mode)=COMPRESS_2PASS_BITRATE;ENCODING(avg_bitrate)=ui.targetRateControlSpinBox->value();;break; } + // update thread count + QComboBox *threads=ui.comboBoxThreads; + int threadIndex=threads->currentIndex(); + myCopy.general.threads=listOfThreads[threadIndex].idcValue; + int t=ui.trellisComboBox->currentIndex(); if(!ui.trellisCheckBox->isChecked()) { @@ -519,6 +653,11 @@ #endif } +void x264Dialog::useAdvancedConfigurationCheckBox_toggled(bool checked) +{ + toogleAdvancedConfiguration(checked); +} + void x264Dialog::quantiserSlider_valueChanged(int value) { ui.quantiserSpinBox->setValue(value); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/qt4/Q_x264.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/qt4/Q_x264.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/qt4/Q_x264.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/qt4/Q_x264.h 2014-03-12 06:15:23.000000000 +0000 @@ -30,6 +30,7 @@ public slots: private slots: + void useAdvancedConfigurationCheckBox_toggled(bool checked); void meSpinBox_valueChanged(int value); void meSlider_valueChanged(int value); void encodingModeComboBox_currentIndexChanged(int index); @@ -46,7 +47,8 @@ bool updatePresetList(void); - + bool toogleAdvancedConfiguration(bool advancedEnabled); + #if 0 void maxCrfSlider_valueChanged(int value); void maxCrfSpinBox_valueChanged(int value); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/qt4/x264ConfigDialog.ui avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/qt4/x264ConfigDialog.ui --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/qt4/x264ConfigDialog.ui 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/qt4/x264ConfigDialog.ui 2014-03-12 06:15:23.000000000 +0000 @@ -7,7 +7,7 @@ 0 0 - 607 + 567 770 @@ -98,121 +98,268 @@ - 5 + 0 - + General - - - - 10 - 10 - 495 - 400 - - - - Rate Control - - - - - - + + + + + Basic + + + + - Target Video Size: + Use advanced configuration - - - - - - 3 + + + + + + Profile: + + + + + + Preset: + + + + + - - Constant Bitrate (Single Pass) - - - - - Constant Quantiser (Single Pass) - + + + -1 + + - - Constant Rate Factor (Single Pass) - + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + - - Video Size (Two Pass) - + - - Average Bitrate (Two Pass) - + + + Qt::Horizontal + + + + 0 + 0 + + + - + - - - - Qt::Horizontal + + + + Tuning: - - - 0 - 0 - + + + + + + IDC Level: - + + + + + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + + + + + + 0 + + + + Auto + + + + + 1 + + + + + 1.1 + + + + + 1.2 + + + + + 1.3 + + + + + 2 + + + + + 2.1 + + + + + 2.2 + + + + + 3 + + + + + 3.1 + + + + + 3.2 + + + + + 4 + + + + + 4.1 + + + + + 4.2 + + + + + 5 + + + + + 5.1 + + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + - - + + - Encoding Mode: + Fast Decode - - + + + + Zero Latency + + + + + + + Fast First Pass + + + + + - - - - - - 999999999 - - - 700 + + + Threads - - - MB - - + - + Qt::Horizontal - 0 - 0 + 40 + 20 @@ -220,321 +367,273 @@ - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 4 - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 0 - - - - - - - - 12 - - - - - 0 + + + + + + Rate Control + + + + + + + + Target Video Size: + + + + - - - 0 + + + 3 - - - false - - - 0 (High Quality) - - + + Constant Bitrate (Single Pass) + - - - Qt::Horizontal - - - - 40 - 20 - - - + + Constant Quantiser (Single Pass) + - - - false - - - Quantiser - - + + Constant Rate Factor (Single Pass) + - - - Qt::Horizontal - - - - 40 - 20 - - - + + Video Size (Two Pass) + - - - false - - - 51 (Low Quality) - - + + Average Bitrate (Two Pass) + - + - - - false + + + Qt::Horizontal - + - 375 + 0 0 - - 51 + + + + + + + + Encoding Mode: + + + + + + + + + - - 5 + + 999999999 - 26 + 700 + + + + + + MB + + + + + Qt::Horizontal - - QSlider::TicksBelow + + + 0 + 0 + - + + + + + - - - false + + + Qt::Horizontal - - 51 + + QSizePolicy::Fixed - - 26 + + + 20 + 0 + - + - - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - - - Maximum Constant Rate Factor - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 0 - - - - - - - - 12 - - + - 0 + 12 - + 0 - - - false - - - 0 (High Quality) + + + 0 - + + + + false + + + 0 (High Quality) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Quantiser + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + 51 (Low Quality) + + + + - - - Qt::Horizontal + + + false - + - 40 - 20 + 375 + 0 - - - - - - false + + 51 - - Quantiser + + 5 + + + 26 - - - - Qt::Horizontal - - - 40 - 20 - - - - - - - - false - - - 51 (Low Quality) + + QSlider::TicksBelow - + false - - - 375 - 0 - - 51 - - 5 - 26 - - Qt::Horizontal - - - QSlider::TicksBelow - - - - false - - - 51 + + + Qt::Horizontal - - 26 + + + 0 + 0 + - + - - + + - Qt::Horizontal + Qt::Vertical @@ -545,168 +644,179 @@ - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 4 - - - - - - - - Fast First Pass - - - - - - - Macroblock-tree Rate Control - - - - - - - - - Frametype Lookahead: - - - - - - - 250 - - - + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Advanced RC + + + + + + Advanced Rate Control + + - + - frames + Maximum Constant Rate Factor - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - - - + - - - 0 + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 0 + + + + + + + + 12 - - Auto - - - - - 1 - - - - - 1.1 - - - - - 1.2 - - - - - 1.3 - - - - - 2 - - - - - 2.1 - - - - - 2.2 - - - - - 3 - - - - - 3.1 - - - - - 3.2 - - - - - 4 - - - - - 4.1 - - - - - 4.2 - - - - - 5 - + + + 0 + + + + + 0 + + + + + false + + + 0 (High Quality) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Quantiser + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + 51 (Low Quality) + + + + + + + + + false + + + + 375 + 0 + + + + 51 + + + 5 + + + 26 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + + - - 5.1 - + + + false + + + 51 + + + 26 + + - + - + Qt::Horizontal @@ -720,51 +830,38 @@ - - + + - Sequence Parameter Set Identifer: + Macroblock-tree Rate Control - - + + - - - - 0 - - - - - 1 - - - - - 3 - - - - - 7 - - - - - 15 - - - - - 31 - - + + + Frametype Lookahead: + + + + + + + 250 + + + + + + + frames + - + Qt::Horizontal @@ -778,32 +875,87 @@ - - - - IDC Level: - - + + + + + + Sequence Parameter Set Identifer: + + + + + + + + + + 0 + + + + + 1 + + + + + 3 + + + + + 7 + + + + + 15 + + + + + 31 + + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - + Motion @@ -1272,7 +1424,7 @@ - + Partition @@ -1347,7 +1499,7 @@ - + Frame @@ -1889,7 +2041,7 @@ - + Analysis @@ -2241,7 +2393,7 @@ - + Quantiser @@ -2778,7 +2930,7 @@ - + Advanced 1 @@ -3091,7 +3243,7 @@ - + Advanced 2 @@ -3236,7 +3388,7 @@ - + Output 1 @@ -3430,7 +3582,7 @@ - + Output 2 @@ -3905,13 +4057,7 @@ targetRateControlSpinBox quantiserSlider quantiserSpinBox - maxCrfCheckBox - maxCrfSlider - maxCrfSpinBox psychoTrellisSpinBox - fastFirstPassCheckBox - mbTreeCheckBox - lookaheadSpinBox meMethodComboBox meSlider meSpinBox @@ -4331,86 +4477,6 @@ - - maxCrfCheckBox - toggled(bool) - quantiserLabel1_2 - setEnabled(bool) - - - 263 - 248 - - - 97 - 277 - - - - - maxCrfCheckBox - toggled(bool) - quantiserLabel2_2 - setEnabled(bool) - - - 263 - 248 - - - 244 - 277 - - - - - maxCrfCheckBox - toggled(bool) - quantiserLabel3_2 - setEnabled(bool) - - - 263 - 248 - - - 393 - 277 - - - - - maxCrfCheckBox - toggled(bool) - maxCrfSlider - setEnabled(bool) - - - 263 - 248 - - - 246 - 300 - - - - - maxCrfCheckBox - toggled(bool) - maxCrfSpinBox - setEnabled(bool) - - - 263 - 248 - - - 467 - 289 - - - openGopCheckBox toggled(bool) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder.conf avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder.conf --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder.conf 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder.conf 2014-03-12 06:15:23.000000000 +0000 @@ -1,10 +1,16 @@ x264_encoder{ +bool:useAdvancedConfiguration general{ video_encode:params; uint32_t:threads; +string:preset; +string:tuning; +string:profile; +bool:fast_decode; +bool:zero_latency; bool:fast_first_pass; } -uint32_t:level +int32_t:level vui{ uint32_t:sar_height; uint32_t:sar_width; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder_desc.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder_desc.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder_desc.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder_desc.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -1,9 +1,15 @@ // automatically generated by admSerialization.py, do not edit! extern const ADM_paramList x264_encoder_param[]={ + {"useAdvancedConfiguration",offsetof(x264_encoder,useAdvancedConfiguration),"bool",ADM_param_bool}, {"general.params",offsetof(x264_encoder,general.params),"COMPRES_PARAMS",ADM_param_video_encode}, {"general.threads",offsetof(x264_encoder,general.threads),"uint32_t",ADM_param_uint32_t}, + {"general.preset",offsetof(x264_encoder,general.preset),"char *",ADM_param_string}, + {"general.tuning",offsetof(x264_encoder,general.tuning),"char *",ADM_param_string}, + {"general.profile",offsetof(x264_encoder,general.profile),"char *",ADM_param_string}, + {"general.fast_decode",offsetof(x264_encoder,general.fast_decode),"bool",ADM_param_bool}, + {"general.zero_latency",offsetof(x264_encoder,general.zero_latency),"bool",ADM_param_bool}, {"general.fast_first_pass",offsetof(x264_encoder,general.fast_first_pass),"bool",ADM_param_bool}, - {"level",offsetof(x264_encoder,level),"uint32_t",ADM_param_uint32_t}, + {"level",offsetof(x264_encoder,level),"int32_t",ADM_param_int32_t}, {"vui.sar_height",offsetof(x264_encoder,vui.sar_height),"uint32_t",ADM_param_uint32_t}, {"vui.sar_width",offsetof(x264_encoder,vui.sar_width),"uint32_t",ADM_param_uint32_t}, {"MaxRefFrames",offsetof(x264_encoder,MaxRefFrames),"uint32_t",ADM_param_uint32_t}, diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder.h 2014-03-12 06:15:23.000000000 +0000 @@ -2,12 +2,18 @@ #ifndef ADM_x264_encoder_CONF_H #define ADM_x264_encoder_CONF_H typedef struct { +bool useAdvancedConfiguration; struct { COMPRES_PARAMS params; uint32_t threads; + char * preset; + char * tuning; + char * profile; + bool fast_decode; + bool zero_latency; bool fast_first_pass; }general; -uint32_t level; +int32_t level; struct { uint32_t sar_height; uint32_t sar_width; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder_json.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder_json.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder_json.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoEncoder/x264/x264_encoder_json.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -5,12 +5,18 @@ #include "x264_encoder.h" bool x264_encoder_jserialize(const char *file, const x264_encoder *key){ admJson json; +json.addBool("useAdvancedConfiguration",key->useAdvancedConfiguration); json.addNode("general"); json.addCompressParam("params",key->general.params); json.addUint32("threads",key->general.threads); +json.addString("preset",key->general.preset); +json.addString("tuning",key->general.tuning); +json.addString("profile",key->general.profile); +json.addBool("fast_decode",key->general.fast_decode); +json.addBool("zero_latency",key->general.zero_latency); json.addBool("fast_first_pass",key->general.fast_first_pass); json.endNode(); -json.addUint32("level",key->level); +json.addInt32("level",key->level); json.addNode("vui"); json.addUint32("sar_height",key->vui.sar_height); json.addUint32("sar_width",key->vui.sar_width); @@ -83,7 +89,7 @@ bool x264_encoder_jdeserialize(const char *file, const ADM_paramList *tmpl,x264_encoder *key){ admJsonToCouple json; CONFcouple *c=json.readFromFile(file); -if(!c) {ADM_error("Cannot read json file (%s)\n",file);return false;} +if(!c) {ADM_error("Cannot read json file");return false;} bool r= ADM_paramLoadPartial(c,tmpl,key); delete c; return r; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/admPackage.txt avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/admPackage.txt --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/admPackage.txt 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/admPackage.txt 2014-03-12 06:15:23.000000000 +0000 @@ -1,5 +1,5 @@ Name : libass URL : https://code.google.com/p/libass/ License : GPL >=2 -Version : 0.10.1 +Version : 0.10.2 diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_bitmap.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_bitmap.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_bitmap.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_bitmap.c 2014-03-12 06:15:23.000000000 +0000 @@ -456,7 +456,7 @@ FT_Library ftlib, FT_Outline *outline, FT_Outline *border, Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s, int be, double blur_radius, FT_Vector shadow_offset, - int border_style) + int border_style, int border_visible) { blur_radius *= 2; int bbord = be > 0 ? sqrt(2 * be) : 0; @@ -485,7 +485,7 @@ while (be--) { if (*bm_o) be_blur(*bm_o); - else + if (!*bm_o || border_style == 3) be_blur(*bm_g); } @@ -493,7 +493,7 @@ if (blur_radius > 0.0) { if (*bm_o) resize_tmp(priv_blur, (*bm_o)->w, (*bm_o)->h); - else + if (!*bm_o || border_style == 3) resize_tmp(priv_blur, (*bm_g)->w, (*bm_g)->h); generate_tables(priv_blur, blur_radius); if (*bm_o) @@ -501,7 +501,7 @@ (*bm_o)->w, (*bm_o)->h, (*bm_o)->stride, (int *) priv_blur->gt2, priv_blur->g_r, priv_blur->g_w); - else + if (!*bm_o || border_style == 3) ass_gauss_blur((*bm_g)->buffer, priv_blur->tmp, (*bm_g)->w, (*bm_g)->h, (*bm_g)->stride, (int *) priv_blur->gt2, priv_blur->g_r, @@ -512,8 +512,11 @@ if (*bm_o && border_style != 3) { *bm_s = copy_bitmap(*bm_o); fix_outline(*bm_g, *bm_o); - } else if (*bm_o) { + } else if (*bm_o && border_visible) { *bm_s = copy_bitmap(*bm_o); + } else if (*bm_o) { + *bm_s = *bm_o; + *bm_o = 0; } else *bm_s = copy_bitmap(*bm_g); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_bitmap.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_bitmap.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_bitmap.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_bitmap.h 2014-03-12 06:15:23.000000000 +0000 @@ -46,12 +46,13 @@ * \param bm_o out: pointer to the bitmap of outline (border) glyph is returned here * \param bm_g out: pointer to the bitmap of glyph shadow is returned here * \param be 1 = produces blurred bitmaps, 0 = normal bitmaps + * \param border_visible whether border is visible if border_style is 3 */ int outline_to_bitmap3(ASS_Library *library, ASS_SynthPriv *priv_blur, FT_Library ftlib, FT_Outline *outline, FT_Outline *border, Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s, int be, double blur_radius, FT_Vector shadow_offset, - int border_style); + int border_style, int border_visible); void ass_free_bitmap(Bitmap *bm); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass.c 2014-03-12 06:15:23.000000000 +0000 @@ -240,6 +240,13 @@ target->name = strdup(token); \ ass_msg(track->library, MSGL_DBG2, "%s = %s", #name, token); +#define STARREDSTRVAL(name) \ + } else if (strcasecmp(tname, #name) == 0) { \ + if (target->name != NULL) free(target->name); \ + while (*token == '*') ++token; \ + target->name = strdup(token); \ + ass_msg(track->library, MSGL_DBG2, "%s = %s", #name, token); + #define COLORVAL(name) \ } else if (strcasecmp(tname, #name) == 0) { \ target->name = string2color(track->library, token); \ @@ -387,6 +394,8 @@ track->ScaledBorderAndShadow = parse_bool(token); else if (!strcasecmp(*fs, "Kerning")) track->Kerning = parse_bool(token); + else if (!strcasecmp(*fs, "YCbCr Matrix")) + track->YCbCrMatrix = parse_ycbcr_matrix(token); dt = strrchr(*fs, '.'); if (dt) { @@ -424,6 +433,7 @@ FPVAL(ScaleY) FPVAL(Outline) FPVAL(Shadow) + FPVAL(Blur) } } } @@ -495,10 +505,9 @@ NEXT(p, token); if (0) { // cool ;) - STRVAL(Name) - if ((strcmp(target->Name, "Default") == 0) - || (strcmp(target->Name, "*Default") == 0)) - track->default_style = sid; + STARREDSTRVAL(Name) + if (strcmp(target->Name, "Default") == 0) + track->default_style = sid; STRVAL(FontName) COLORVAL(PrimaryColour) COLORVAL(SecondaryColour) @@ -514,7 +523,7 @@ INTVAL(Underline) INTVAL(StrikeOut) FPVAL(Spacing) - INTVAL(Angle) + FPVAL(Angle) INTVAL(BorderStyle) INTVAL(Alignment) if (track->track_type == TRACK_TYPE_ASS) @@ -573,6 +582,8 @@ track->ScaledBorderAndShadow = parse_bool(str + 22); } else if (!strncmp(str, "Kerning:", 8)) { track->Kerning = parse_bool(str + 8); + } else if (!strncmp(str, "YCbCr Matrix:", 13)) { + track->YCbCrMatrix = parse_ycbcr_matrix(str + 13); } else if (!strncmp(str, "Language:", 9)) { char *p = str + 9; while (*p && isspace(*p)) p++; @@ -587,10 +598,10 @@ { track->parser_priv->state = PST_EVENTS; if (track->track_type == TRACK_TYPE_SSA) - track->event_format = strdup("Format: Marked, Start, End, Style, " + track->event_format = strdup("Marked, Start, End, Style, " "Name, MarginL, MarginR, MarginV, Effect, Text"); else - track->event_format = strdup("Format: Layer, Start, End, Style, " + track->event_format = strdup("Layer, Start, End, Style, " "Actor, MarginL, MarginR, MarginV, Effect, Text"); ass_msg(track->library, MSGL_V, "No event format found, using fallback"); @@ -957,6 +968,11 @@ ass_msg(library, MSGL_V, "Opened iconv descriptor"); } else ass_msg(library, MSGL_ERR, "Error opening iconv descriptor"); +#ifdef CONFIG_ENCA + if (cp_tmp != codepage) { + free((void*)cp_tmp); + } +#endif } { @@ -988,7 +1004,9 @@ oleft += size; } else { ass_msg(library, MSGL_WARN, "Error recoding file"); - return NULL; + free(outbuf); + outbuf = NULL; + goto out; } } else if (clear) break; @@ -996,6 +1014,7 @@ outbuf[osize - oleft - 1] = 0; } +out: if (icdsc != (iconv_t) (-1)) { (void) iconv_close(icdsc); icdsc = (iconv_t) (-1); @@ -1103,7 +1122,7 @@ size_t bufsize, char *codepage) { ASS_Track *track; - int need_free = 0; + int copied = 0; if (!buf) return 0; @@ -1114,12 +1133,19 @@ if (!buf) return 0; else - need_free = 1; + copied = 1; } #endif + if (!copied) { + char *newbuf = malloc(bufsize + 1); + if (!newbuf) + return 0; + memcpy(newbuf, buf, bufsize); + newbuf[bufsize] = '\0'; + buf = newbuf; + } track = parse_memory(library, buf); - if (need_free) - free(buf); + free(buf); if (!track) return 0; @@ -1216,33 +1242,45 @@ long long ass_step_sub(ASS_Track *track, long long now, int movement) { int i; + ASS_Event *best = NULL; + long long target = now; + int direction = movement > 0 ? 1 : -1; if (movement == 0) return 0; if (track->n_events == 0) return 0; - if (movement < 0) - for (i = 0; - (i < track->n_events) - && - ((long long) (track->events[i].Start + - track->events[i].Duration) <= now); ++i) { - } else - for (i = track->n_events - 1; - (i >= 0) && ((long long) (track->events[i].Start) > now); - --i) { - } - - // -1 and n_events are ok - assert(i >= -1); - assert(i <= track->n_events); - i += movement; - if (i < 0) - i = 0; - if (i >= track->n_events) - i = track->n_events - 1; - return ((long long) track->events[i].Start) - now; + while (movement) { + ASS_Event *closest = NULL; + long long closest_time = now; + for (i = 0; i < track->n_events; i++) { + if (direction < 0) { + long long end = + track->events[i].Start + track->events[i].Duration; + if (end < target) { + if (!closest || end > closest_time) { + closest = &track->events[i]; + closest_time = end; + } + } + } else { + long long start = track->events[i].Start; + if (start > target) { + if (!closest || start < closest_time) { + closest = &track->events[i]; + closest_time = start; + } + } + } + } + target = closest_time + direction; + movement -= direction; + if (closest) + best = closest; + } + + return best ? best->Start - now : 0; } ASS_Track *ass_new_track(ASS_Library *library) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_font.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_font.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_font.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_font.c 2014-03-12 06:15:23.000000000 +0000 @@ -223,7 +223,8 @@ // The idea was borrowed from asa (http://asa.diac24.net) if (hori && os2) { int hori_height = hori->Ascender - hori->Descender; - int os2_height = os2->usWinAscent + os2->usWinDescent; + /* sometimes used for signed values despite unsigned in spec */ + int os2_height = (short)os2->usWinAscent + (short)os2->usWinDescent; if (hori_height && os2_height) mscale = (double) hori_height / os2_height; } @@ -266,8 +267,8 @@ if (FT_Get_Char_Index(face, ch)) { int y_scale = face->size->metrics.y_scale; if (os2) { - *asc = FT_MulFix(os2->usWinAscent, y_scale); - *desc = FT_MulFix(os2->usWinDescent, y_scale); + *asc = FT_MulFix((short)os2->usWinAscent, y_scale); + *desc = FT_MulFix((short)os2->usWinDescent, y_scale); } else { *asc = FT_MulFix(face->ascender, y_scale); *desc = FT_MulFix(-face->descender, y_scale); @@ -711,12 +712,12 @@ /* "inside" contour but we can't find anything it could be * inside of - assume the font is buggy and it should be * an "outside" contour, and reverse it */ - for (j = 0; j < (end + 1 - start) / 2; j++) { - FT_Vector temp = outline->points[start + j]; - char temp2 = outline->tags[start + j]; - outline->points[start + j] = outline->points[end - j]; + for (j = 0; j < (end - start) / 2; j++) { + FT_Vector temp = outline->points[start + 1 + j]; + char temp2 = outline->tags[start + 1 + j]; + outline->points[start + 1 + j] = outline->points[end - j]; outline->points[end - j] = temp; - outline->tags[start + j] = outline->tags[end - j]; + outline->tags[start + 1 + j] = outline->tags[end - j]; outline->tags[end - j] = temp2; } dir ^= 1; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_fontconfig.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_fontconfig.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_fontconfig.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_fontconfig.c 2014-03-12 06:15:23.000000000 +0000 @@ -179,6 +179,14 @@ rc = FcConfigSubstitute(priv->config, pat, FcMatchPattern); if (!rc) goto error; + /* Fontconfig defaults include a language setting, which it sets based on + * some environment variables or defaults to "en". Unset this as we don't + * know the real language, and because some some attached fonts lack + * non-ascii characters included in fontconfig's list of characters + * required for English support and therefore don't match the lang=en + * criterion. + */ + FcPatternDel(pat, "lang"); fsorted = FcFontSort(priv->config, pat, FcTrue, NULL, &result); ffullname = match_fullname(library, priv, family, bold, italic); @@ -249,11 +257,18 @@ if (!treat_family_as_pattern && !(r_family && strcasecmp((const char *) r_family, family) == 0) && - !(r_fullname && strcasecmp((const char *) r_fullname, family) == 0)) - ass_msg(library, MSGL_WARN, - "fontconfig: Selected font is not the requested one: " - "'%s' != '%s'", - (const char *) (r_fullname ? r_fullname : r_family), family); + !(r_fullname && strcasecmp((const char *) r_fullname, family) == 0)) { + char *fallback = (char *) (r_fullname ? r_fullname : r_family); + if (code) { + ass_msg(library, MSGL_WARN, + "fontconfig: cannot find glyph U+%04X in font '%s', falling back to '%s'", + (unsigned int)code, family, fallback); + } else { + ass_msg(library, MSGL_WARN, + "fontconfig: cannot find font '%s', falling back to '%s'", + family, fallback); + } + } result = FcPatternGetString(rpat, FC_STYLE, 0, &r_style); if (result != FcResultMatch) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass.h 2014-03-12 06:15:23.000000000 +0000 @@ -23,7 +23,7 @@ #include #include "ass_types.h" -#define LIBASS_VERSION 0x01010000 +#define LIBASS_VERSION 0x01020000 /* * A linked list of images produced by an ass renderer. @@ -44,11 +44,25 @@ int dst_x, dst_y; // Bitmap placement inside the video frame struct ass_image *next; // Next image, or NULL + + enum { + IMAGE_TYPE_CHARACTER, + IMAGE_TYPE_OUTLINE, + IMAGE_TYPE_SHADOW + } type; + } ASS_Image; /* * Hinting type. (see ass_set_hinting below) * + * Setting hinting to anything but ASS_HINTING_NONE will put libass in a mode + * that reduces compatibility with vsfilter and many ASS scripts. The main + * problem is that hinting conflicts with smooth scaling, which precludes + * animations and precise positioning. + * + * In other words, enabling hinting might break some scripts severely. + * * FreeType's native hinter is still buggy sometimes and it is recommended * to use the light autohinter, ASS_HINTING_LIGHT, instead. For best * compatibility with problematic fonts, disable hinting. @@ -153,6 +167,12 @@ /** * \brief Set the frame size in pixels, including margins. + * The renderer will never return images that are outside of the frame area. + * The value set with this function can influence the pixel aspect ratio used + * for rendering. If the frame size doesn't equal to the video size, you may + * have to use ass_set_pixel_aspect(). + * @see ass_set_pixel_aspect() + * @see ass_set_margins() * \param priv renderer handle * \param w width * \param h height @@ -160,6 +180,19 @@ void ass_set_frame_size(ASS_Renderer *priv, int w, int h); /** + * \brief Set the source image size in pixels. + * This is used to calculate the source aspect ratio and the blur scale. + * The source image size can be reset to default by setting w and h to 0. + * The value set with this function can influence the pixel aspect ratio used + * for rendering. + * @see ass_set_pixel_aspect() + * \param priv renderer handle + * \param w width + * \param h height + */ +void ass_set_storage_size(ASS_Renderer *priv, int w, int h); + +/** * \brief Set shaping level. This is merely a hint, the renderer will use * whatever is available if the request cannot be fulfilled. * \param level shaping level @@ -168,7 +201,26 @@ /** * \brief Set frame margins. These values may be negative if pan-and-scan - * is used. + * is used. The margins are in pixels. Each value specifies the distance from + * the video rectangle to the renderer frame. If a given margin value is + * positive, there will be free space between renderer frame and video area. + * If a given margin value is negative, the frame is inside the video, i.e. + * the video has been cropped. + * + * The renderer will try to keep subtitles inside the frame area. If possible, + * text is layout so that it is inside the cropped area. Subtitle events + * that can't be moved are cropped against the frame area. + * + * ass_set_use_margins() can be used to allow libass to render subtitles into + * the empty areas if margins are positive, i.e. the video area is smaller than + * the frame. (Traditionally, this has been used to show subtitles in + * the bottom "black bar" between video bottom screen border when playing 16:9 + * video on a 4:3 screen.) + * + * When using this function, it is recommended to calculate and set your own + * aspect ratio with ass_set_pixel_aspect(), as the defaults won't make any + * sense. + * @see ass_set_pixel_aspect() * \param priv renderer handle * \param t top margin * \param b bottom margin @@ -185,7 +237,29 @@ void ass_set_use_margins(ASS_Renderer *priv, int use); /** + * \brief Set pixel aspect ratio correction. + * This is the ratio of pixel width to pixel height. + * + * Generally, this is (s_w / s_h) / (d_w / d_h), where s_w and s_h is the + * video storage size, and d_w and d_h is the video display size. (Display + * and storage size can be different for anamorphic video, such as DVDs.) + * + * If the pixel aspect ratio is 0, or if the aspect ratio has never been set + * by calling this function, libass will calculate a default pixel aspect ratio + * out of values set with ass_set_frame_size() and ass_set_storage_size(). Note + * that this is useful only if the frame size corresponds to the video display + * size. Keep in mind that the margins set with ass_set_margins() are ignored + * for aspect ratio calculations as well. + * If the storage size has not been set, a pixel aspect ratio of 1 is assumed. + * \param priv renderer handle + * \param par pixel aspect ratio (1.0 means square pixels, 0 means default) + */ +void ass_set_pixel_aspect(ASS_Renderer *priv, double par); + +/** * \brief Set aspect ratio parameters. + * This calls ass_set_pixel_aspect(priv, dar / sar). + * @deprecated New code should use ass_set_pixel_aspect(). * \param priv renderer handle * \param dar display aspect ratio (DAR), prescaled for output PAR * \param sar storage aspect ratio (SAR) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_parse.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_parse.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_parse.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_parse.c 2014-03-12 06:15:23.000000000 +0000 @@ -241,7 +241,7 @@ drawing->scale = scale; drawing->scale_x = render_priv->font_scale_x * render_priv->font_scale; drawing->scale_y = render_priv->font_scale; - while (*p != ')' && *p != '}' && p != 0) + while (*p != ')' && *p != '}' && *p != 0) ass_drawing_add_char(drawing, *p++); skipopt(')'); @@ -311,7 +311,7 @@ int x0, y0, x1, y1; int res = 1; char *start = p; - skipopt('('); + skip('('); res &= mystrtoi(&p, &x0); skipopt(','); res &= mystrtoi(&p, &y0); @@ -418,6 +418,7 @@ mystrtod(&p, &x2); skip(','); mystrtod(&p, &y2); + t1 = t2 = 0; if (*p == ',') { skip(','); mystrtoll(&p, &t1); @@ -427,13 +428,20 @@ "movement6: (%f, %f) -> (%f, %f), (%" PRId64 " .. %" PRId64 ")\n", x1, y1, x2, y2, (int64_t) t1, (int64_t) t2); - } else { + // VSFilter + if (t1 > t2) { + double tmp = t2; + t2 = t1; + t1 = tmp; + } + } + if (t1 <= 0 && t2 <= 0) { t1 = 0; t2 = render_priv->state.event->Duration; ass_msg(render_priv->library, MSGL_DBG2, "movement: (%f, %f) -> (%f, %f)", x1, y1, x2, y2); } - skip(')'); + skipopt(')'); delta_t = t2 - t1; t = render_priv->time - render_priv->state.event->Start; if (t < t1) @@ -542,7 +550,7 @@ mystrtod(&p, &v1); skip(','); mystrtod(&p, &v2); - skip(')'); + skipopt(')'); ass_msg(render_priv->library, MSGL_DBG2, "pos(%f, %f)", v1, v2); if (render_priv->state.evt_type == EVENT_POSITIONED) { ass_msg(render_priv->library, MSGL_V, "Subtitle has a new \\pos " @@ -586,7 +594,7 @@ skip(','); mystrtoll(&p, &t4); } - skip(')'); + skipopt(')'); if ((render_priv->state.parsed_tags & PARSED_FADE) == 0) { render_priv->state.fade = interpolate_alpha(render_priv->time - @@ -600,7 +608,7 @@ mystrtoi(&p, &v1); skip(','); mystrtoi(&p, &v2); - skip(')'); + skipopt(')'); ass_msg(render_priv->library, MSGL_DBG2, "org(%d, %d)", v1, v2); if (!render_priv->state.have_origin) { render_priv->state.org_x = v1; @@ -617,9 +625,8 @@ double k; skip('('); for (cnt = 0; cnt < 3; ++cnt) { - if (*p == '\\') + if (!mystrtod(&p, &v[cnt])) break; - mystrtod(&p, &v[cnt]); skip(','); } if (cnt == 3) { @@ -654,15 +661,15 @@ assert(delta_t != 0.); k = pow(((double) (t - t1)) / delta_t, v3); } - while (*p == '\\') + while (*p != ')' && *p != '}' && *p != '\0') p = parse_tag(render_priv, p, k); // maybe k*pwr ? no, specs forbid nested \t's skip_to(')'); // in case there is some unknown tag or a comment - skip(')'); + skipopt(')'); } else if (mystrcmp(&p, "clip")) { char *start = p; int x0, y0, x1, y1; int res = 1; - skipopt('('); + skip('('); res &= mystrtoi(&p, &x0); skipopt(','); res &= mystrtoi(&p, &y0); @@ -749,7 +756,7 @@ strncpy(style, start, p - start); style[p - start] = '\0'; reset_render_context(render_priv, - render_priv->track->styles + lookup_style(render_priv->track, style)); + lookup_style_strict(render_priv->track, style)); free(style); } else reset_render_context(render_priv, NULL); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render_api.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render_api.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render_api.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render_api.c 2014-03-12 06:15:23.000000000 +0000 @@ -43,6 +43,13 @@ priv->orig_height_nocrop = settings->frame_height - FFMAX(settings->top_margin, 0) - FFMAX(settings->bottom_margin, 0); + if (settings->storage_height) { + priv->storage_width = settings->storage_width; + priv->storage_height = settings->storage_height; + } else { + priv->storage_width = priv->orig_width; + priv->storage_height = priv->orig_height; + } } void ass_set_frame_size(ASS_Renderer *priv, int w, int h) @@ -50,10 +57,16 @@ if (priv->settings.frame_width != w || priv->settings.frame_height != h) { priv->settings.frame_width = w; priv->settings.frame_height = h; - if (priv->settings.aspect == 0.) { - priv->settings.aspect = ((double) w) / h; - priv->settings.storage_aspect = ((double) w) / h; - } + ass_reconfigure(priv); + } +} + +void ass_set_storage_size(ASS_Renderer *priv, int w, int h) +{ + if (priv->settings.storage_width != w || + priv->settings.storage_height != h) { + priv->settings.storage_width = w; + priv->settings.storage_height = h; ass_reconfigure(priv); } } @@ -88,9 +101,13 @@ void ass_set_aspect_ratio(ASS_Renderer *priv, double dar, double sar) { - if (priv->settings.aspect != dar || priv->settings.storage_aspect != sar) { - priv->settings.aspect = dar; - priv->settings.storage_aspect = sar; + ass_set_pixel_aspect(priv, dar / sar); +} + +void ass_set_pixel_aspect(ASS_Renderer *priv, double par) +{ + if (priv->settings.par != par) { + priv->settings.par = par; ass_reconfigure(priv); } } diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render.c 2014-03-12 06:15:23.000000000 +0000 @@ -240,7 +240,7 @@ static ASS_Image **render_glyph_i(ASS_Renderer *render_priv, Bitmap *bm, int dst_x, int dst_y, uint32_t color, uint32_t color2, int brk, - ASS_Image **tail) + ASS_Image **tail, unsigned int type) { int i, j, x0, y0, x1, y1, cx0, cy0, cx1, cy1, sx, sy, zx, zy; Rect r[4]; @@ -308,6 +308,7 @@ lbrk - r[j].x0, r[j].y1 - r[j].y0, bm->stride, dst_x + r[j].x0, dst_y + r[j].y0, color); if (!img) break; + img->type = type; *tail = img; tail = &img->next; } @@ -317,6 +318,7 @@ r[j].x1 - lbrk, r[j].y1 - r[j].y0, bm->stride, dst_x + lbrk, dst_y + r[j].y0, color2); if (!img) break; + img->type = type; *tail = img; tail = &img->next; } @@ -339,12 +341,12 @@ */ static ASS_Image ** render_glyph(ASS_Renderer *render_priv, Bitmap *bm, int dst_x, int dst_y, - uint32_t color, uint32_t color2, int brk, ASS_Image **tail) + uint32_t color, uint32_t color2, int brk, ASS_Image **tail, unsigned int type) { // Inverse clipping in use? if (render_priv->state.clip_mode) return render_glyph_i(render_priv, bm, dst_x, dst_y, color, color2, - brk, tail); + brk, tail, type); // brk is relative to dst_x // color = color left of brk @@ -399,6 +401,7 @@ brk - b_x0, b_y1 - b_y0, bm->stride, dst_x + b_x0, dst_y + b_y0, color); if (!img) return tail; + img->type = type; *tail = img; tail = &img->next; } @@ -409,6 +412,7 @@ b_x1 - brk, b_y1 - b_y0, bm->stride, dst_x + brk, dst_y + b_y0, color2); if (!img) return tail; + img->type = type; *tail = img; tail = &img->next; } @@ -546,7 +550,6 @@ ASS_Drawing *drawing = render_priv->state.clip_drawing; BitmapHashKey key; BitmapHashValue *val; - int error; if (!drawing) return; @@ -586,10 +589,6 @@ clip_bm = outline_to_bitmap(render_priv->library, render_priv->ftlibrary, outline, 0); - if (clip_bm == NULL) { - ass_msg(render_priv->library, MSGL_WARN, - "Clip vector rasterization failed: %d. Skipping.", error); - } // Add to cache memset(&v, 0, sizeof(v)); @@ -683,6 +682,8 @@ render_priv->state.clip_drawing = 0; } +#define IS_SKIP_SYMBOL(x) ((x) == 0 || (x) == '\n' || (x) == '\r') + /** * \brief Convert TextInfo struct to ASS_Image list * Splits glyphs in halves when needed (for \kf karaoke). @@ -700,7 +701,7 @@ for (i = 0; i < text_info->length; ++i) { GlyphInfo *info = text_info->glyphs + i; - if ((info->symbol == 0) || (info->symbol == '\n') || !info->bm_s + if (IS_SKIP_SYMBOL(info->symbol) || !info->bm_s || (info->shadow_x == 0 && info->shadow_y == 0) || info->skip) continue; @@ -721,7 +722,7 @@ here_tail = tail; tail = render_glyph(render_priv, bm, pen_x, pen_y, info->c[3], 0, - 1000000, tail); + 1000000, tail, IMAGE_TYPE_SHADOW); if (last_tail && tail != here_tail && ((info->c[3] & 0xff) > 0)) render_overlap(render_priv, last_tail, here_tail); @@ -734,7 +735,7 @@ last_tail = 0; for (i = 0; i < text_info->length; ++i) { GlyphInfo *info = text_info->glyphs + i; - if ((info->symbol == 0) || (info->symbol == '\n') || !info->bm_o + if (IS_SKIP_SYMBOL(info->symbol) || !info->bm_o || info->skip) continue; @@ -755,7 +756,7 @@ here_tail = tail; tail = render_glyph(render_priv, bm, pen_x, pen_y, info->c[2], - 0, 1000000, tail); + 0, 1000000, tail, IMAGE_TYPE_OUTLINE); if (last_tail && tail != here_tail && ((info->c[2] & 0xff) > 0)) render_overlap(render_priv, last_tail, here_tail); @@ -767,7 +768,7 @@ for (i = 0; i < text_info->length; ++i) { GlyphInfo *info = text_info->glyphs + i; - if ((info->symbol == 0) || (info->symbol == '\n') || !info->bm + if (IS_SKIP_SYMBOL(info->symbol) || !info->bm || info->skip) continue; @@ -786,19 +787,19 @@ if (info->effect_timing > (info->bbox.xMax >> 6)) tail = render_glyph(render_priv, bm, pen_x, pen_y, - info->c[0], 0, 1000000, tail); + info->c[0], 0, 1000000, tail, IMAGE_TYPE_CHARACTER); else tail = render_glyph(render_priv, bm, pen_x, pen_y, - info->c[1], 0, 1000000, tail); + info->c[1], 0, 1000000, tail, IMAGE_TYPE_CHARACTER); } else if (info->effect_type == EF_KARAOKE_KF) { tail = render_glyph(render_priv, bm, pen_x, pen_y, info->c[0], - info->c[1], info->effect_timing, tail); + info->c[1], info->effect_timing, tail, IMAGE_TYPE_CHARACTER); } else tail = render_glyph(render_priv, bm, pen_x, pen_y, info->c[0], - 0, 1000000, tail); + 0, 1000000, tail, IMAGE_TYPE_CHARACTER); info = info->next; } } @@ -869,7 +870,7 @@ render_priv->state.scale_y = style->ScaleY; render_priv->state.hspacing = style->Spacing; render_priv->state.be = 0; - render_priv->state.blur = 0.0; + render_priv->state.blur = style->Blur; render_priv->state.shadow_x = style->Shadow; render_priv->state.shadow_y = style->Shadow; render_priv->state.frx = render_priv->state.fry = 0.; @@ -930,13 +931,14 @@ * Replace the outline of a glyph by a contour which makes up a simple * opaque rectangle. */ -static void draw_opaque_box(ASS_Renderer *render_priv, int asc, int desc, - FT_Outline *ol, FT_Vector advance, int sx, int sy) +static void draw_opaque_box(ASS_Renderer *render_priv, GlyphInfo *info, + int asc, int desc, FT_Outline *ol, + FT_Vector advance, int sx, int sy) { int i; int adv = advance.x; - double scale_y = render_priv->state.scale_y; - double scale_x = render_priv->state.scale_x; + double scale_y = info->orig_scale_y; + double scale_x = info->orig_scale_x; // to avoid gaps sx = FFMAX(64, sx); @@ -944,8 +946,7 @@ // Emulate the WTFish behavior of VSFilter, i.e. double-scale // the sizes of the opaque box. - adv += double_to_d6(render_priv->state.hspacing * render_priv->font_scale - * scale_x); + adv += double_to_d6(info->hspacing * render_priv->font_scale * scale_x); adv *= scale_x; sx *= scale_x; sy *= scale_y; @@ -1098,14 +1099,10 @@ v.desc = drawing->desc; key.u.drawing.text = strdup(drawing->text); } else { - // arbitrary, not too small to prevent grid fitting rounding effects - // XXX: this is a rather crude hack - const double ft_size = 256.0; - ass_face_set_size(info->font->faces[info->face_index], ft_size); - ass_font_set_transform(info->font, - info->scale_x * info->font_size / ft_size, - info->scale_y * info->font_size / ft_size, - NULL); + ass_face_set_size(info->font->faces[info->face_index], + info->font_size); + ass_font_set_transform(info->font, info->scale_x, + info->scale_y, NULL); FT_Glyph glyph = ass_font_get_glyph(priv->fontconfig_priv, info->font, info->symbol, info->face_index, info->glyph_index, @@ -1120,8 +1117,8 @@ FT_Done_Glyph(glyph); ass_font_get_asc_desc(info->font, info->symbol, &v.asc, &v.desc); - v.asc *= info->scale_y * info->font_size / ft_size; - v.desc *= info->scale_y * info->font_size / ft_size; + v.asc *= info->scale_y; + v.desc *= info->scale_y; } } @@ -1130,8 +1127,7 @@ FT_Outline_Get_CBox(v.outline, &v.bbox_scaled); - if (info->border_style == 3 && - (info->border_x > 0 || info->border_y > 0)) { + if (info->border_style == 3) { FT_Vector advance; v.border = calloc(1, sizeof(FT_Outline)); @@ -1141,7 +1137,7 @@ else advance = info->advance; - draw_opaque_box(priv, v.asc, v.desc, v.border, advance, + draw_opaque_box(priv, info, v.asc, v.desc, v.border, advance, double_to_d6(info->border_x * priv->border_scale), double_to_d6(info->border_y * priv->border_scale)); @@ -1314,9 +1310,10 @@ outline, border, &hash_val.bm, &hash_val.bm_o, &hash_val.bm_s, info->be, - info->blur * render_priv->border_scale, + info->blur * render_priv->blur_scale, key->shadow_offset, - info->border_style); + info->border_style, + info->border_x || info->border_y); if (error) info->symbol = 0; @@ -1674,6 +1671,33 @@ } /** + * \brief Adjust the glyph's font size and scale factors to ensure smooth + * scaling and handle pathological font sizes. The main problem here is + * freetype's grid fitting, which destroys animations by font size, or will + * result in incorrect final text size if font sizes are very small and + * scale factors very large. See Google Code issue #46. + * \param priv guess what + * \param glyph the glyph to be modified + */ +static void +fix_glyph_scaling(ASS_Renderer *priv, GlyphInfo *glyph) +{ + double ft_size; + if (priv->settings.hinting == ASS_HINTING_NONE) { + // arbitrary, not too small to prevent grid fitting rounding effects + // XXX: this is a rather crude hack + ft_size = 256.0; + } else { + // If hinting is enabled, we want to pass the real font size + // to freetype. Normalize scale_y to 1.0. + ft_size = glyph->scale_y * glyph->font_size; + } + glyph->scale_x = glyph->scale_x * glyph->font_size / ft_size; + glyph->scale_y = glyph->scale_y * glyph->font_size / ft_size; + glyph->font_size = ft_size; +} + +/** * \brief Main ass rendering function, glues everything together * \param event event to render * \param event_images struct containing resulting images, will also be initialized @@ -1684,8 +1708,6 @@ EventImages *event_images) { char *p; - FT_UInt previous; - FT_UInt num_glyphs; FT_Vector pen; unsigned code; DBBox bbox; @@ -1712,7 +1734,6 @@ drawing = render_priv->state.drawing; text_info->length = 0; - num_glyphs = 0; p = event->Text; int in_tag = 0; @@ -1761,8 +1782,10 @@ sizeof(GlyphInfo) * text_info->max_glyphs); } + GlyphInfo *info = &glyphs[text_info->length]; + // Clear current GlyphInfo - memset(&glyphs[text_info->length], 0, sizeof(GlyphInfo)); + memset(info, 0, sizeof(GlyphInfo)); // Parse drawing if (drawing->i) { @@ -1771,7 +1794,7 @@ drawing->scale_y = render_priv->state.scale_y * render_priv->font_scale; code = 0xfffc; // object replacement character - glyphs[text_info->length].drawing = drawing; + info->drawing = drawing; } // face could have been changed in get_next_char @@ -1784,44 +1807,45 @@ break; // Fill glyph information - glyphs[text_info->length].symbol = code; - glyphs[text_info->length].font = render_priv->state.font; + info->symbol = code; + info->font = render_priv->state.font; for (i = 0; i < 4; ++i) { uint32_t clr = render_priv->state.c[i]; change_alpha(&clr, mult_alpha(_a(clr), render_priv->state.fade), 1.); - glyphs[text_info->length].c[i] = clr; + info->c[i] = clr; } - glyphs[text_info->length].effect_type = render_priv->state.effect_type; - glyphs[text_info->length].effect_timing = - render_priv->state.effect_timing; - glyphs[text_info->length].effect_skip_timing = - render_priv->state.effect_skip_timing; - glyphs[text_info->length].font_size = - render_priv->state.font_size * render_priv->font_scale; - glyphs[text_info->length].be = render_priv->state.be; - glyphs[text_info->length].blur = render_priv->state.blur; - glyphs[text_info->length].shadow_x = render_priv->state.shadow_x; - glyphs[text_info->length].shadow_y = render_priv->state.shadow_y; - glyphs[text_info->length].scale_x= render_priv->state.scale_x; - glyphs[text_info->length].scale_y = render_priv->state.scale_y; - glyphs[text_info->length].border_style = render_priv->state.border_style; - glyphs[text_info->length].border_x= render_priv->state.border_x; - glyphs[text_info->length].border_y = render_priv->state.border_y; - glyphs[text_info->length].hspacing = render_priv->state.hspacing; - glyphs[text_info->length].bold = render_priv->state.bold; - glyphs[text_info->length].italic = render_priv->state.italic; - glyphs[text_info->length].flags = render_priv->state.flags; - glyphs[text_info->length].frx = render_priv->state.frx; - glyphs[text_info->length].fry = render_priv->state.fry; - glyphs[text_info->length].frz = render_priv->state.frz; - glyphs[text_info->length].fax = render_priv->state.fax; - glyphs[text_info->length].fay = render_priv->state.fay; - glyphs[text_info->length].bm_run_id = render_priv->state.bm_run_id; - if (glyphs[text_info->length].drawing) { + info->effect_type = render_priv->state.effect_type; + info->effect_timing = render_priv->state.effect_timing; + info->effect_skip_timing = render_priv->state.effect_skip_timing; + info->font_size = + render_priv->state.font_size * render_priv->font_scale; + info->be = render_priv->state.be; + info->blur = render_priv->state.blur; + info->shadow_x = render_priv->state.shadow_x; + info->shadow_y = render_priv->state.shadow_y; + info->scale_x = info->orig_scale_x = render_priv->state.scale_x; + info->scale_y = info->orig_scale_y = render_priv->state.scale_y; + info->border_style = render_priv->state.border_style; + info->border_x= render_priv->state.border_x; + info->border_y = render_priv->state.border_y; + info->hspacing = render_priv->state.hspacing; + info->bold = render_priv->state.bold; + info->italic = render_priv->state.italic; + info->flags = render_priv->state.flags; + info->frx = render_priv->state.frx; + info->fry = render_priv->state.fry; + info->frz = render_priv->state.frz; + info->fax = render_priv->state.fax; + info->fay = render_priv->state.fay; + info->bm_run_id = render_priv->state.bm_run_id; + + if (info->drawing) { drawing = render_priv->state.drawing = ass_drawing_new(render_priv->library, render_priv->ftlibrary); + } else { + fix_glyph_scaling(render_priv, info); } text_info->length++; @@ -1875,7 +1899,6 @@ } // Preliminary layout (for line wrapping) - previous = 0; pen.x = 0; pen.y = 0; for (i = 0; i < text_info->length; i++) { @@ -1897,7 +1920,6 @@ info = glyphs + i; pen.x += info->cluster_advance.x; pen.y += info->cluster_advance.y; - previous = info->symbol; } @@ -2229,9 +2251,6 @@ && !render_priv->settings.frame_height) return 1; // library not initialized - if (render_priv->library != track->library) - return 1; - if (!render_priv->fontconfig_priv) return 1; @@ -2247,21 +2266,39 @@ render_priv->font_scale = settings_priv->font_size_coeff * render_priv->orig_height / render_priv->track->PlayResY; + if (render_priv->storage_height) + render_priv->blur_scale = ((double) render_priv->orig_height) / + render_priv->storage_height; + else + render_priv->blur_scale = 1.; if (render_priv->track->ScaledBorderAndShadow) render_priv->border_scale = ((double) render_priv->orig_height) / render_priv->track->PlayResY; else - render_priv->border_scale = 1.; + render_priv->border_scale = render_priv->blur_scale; + if (!settings_priv->storage_height) + render_priv->blur_scale = render_priv->border_scale; + render_priv->border_scale *= settings_priv->font_size_coeff; ass_shaper_set_kerning(render_priv->shaper, track->Kerning); - if (track->Language) - ass_shaper_set_language(render_priv->shaper, track->Language); + ass_shaper_set_language(render_priv->shaper, track->Language); ass_shaper_set_level(render_priv->shaper, render_priv->settings.shaper); // PAR correction - render_priv->font_scale_x = render_priv->settings.aspect / - render_priv->settings.storage_aspect; + double par = render_priv->settings.par; + if (par == 0.) { + if (settings_priv->frame_width && settings_priv->frame_height && + settings_priv->storage_width && settings_priv->storage_height) { + double dar = ((double) settings_priv->frame_width) / + settings_priv->frame_height; + double sar = ((double) settings_priv->storage_width) / + settings_priv->storage_height; + par = sar / dar; + } else + par = 1.0; + } + render_priv->font_scale_x = par; render_priv->prev_images_root = render_priv->images_root; render_priv->images_root = 0; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_render.h 2014-03-12 06:15:23.000000000 +0000 @@ -26,6 +26,9 @@ #include FT_STROKER_H #include FT_GLYPH_H #include FT_SYNTHESIS_H +#ifdef CONFIG_HARFBUZZ +#include "hb.h" +#endif // XXX: fix the inclusion mess so we can avoid doing this here typedef struct ass_shaper ASS_Shaper; @@ -65,6 +68,8 @@ typedef struct { int frame_width; int frame_height; + int storage_width; // width of the source image + int storage_height; // height of the source image double font_size_coeff; // font size multiplier double line_spacing; // additional line spacing (in frame pixels) double line_position; // vertical position for subtitles, 0-100 (0 = no change) @@ -74,8 +79,7 @@ int right_margin; int use_margins; // 0 - place all subtitles inside original frame // 1 - use margins for placing toptitles and subtitles - double aspect; // frame aspect ratio, d_width / d_height. - double storage_aspect; // pixel ratio of the source image + double par; // user defined pixel aspect ratio (0 = unset) ASS_Hinting hinting; ASS_ShapingLevel shaper; @@ -107,6 +111,11 @@ ASS_Font *font; int face_index; int glyph_index; +#ifdef CONFIG_HARFBUZZ + hb_script_t script; +#else + int script; +#endif double font_size; ASS_Drawing *drawing; FT_Outline *outline; @@ -134,6 +143,7 @@ double frx, fry, frz; // rotation double fax, fay; // text shearing double scale_x, scale_y; + double orig_scale_x, orig_scale_y; // scale_x,y before fix_glyph_scaling int border_style; double border_x, border_y; double hspacing; @@ -264,11 +274,14 @@ int orig_width; // frame width ( = screen width - margins ) int orig_height_nocrop; // frame height ( = screen height - margins + cropheight) int orig_width_nocrop; // frame width ( = screen width - margins + cropwidth) + int storage_height; // video height before any rescaling + int storage_width; // video width before any rescaling ASS_Track *track; long long time; // frame's timestamp, ms double font_scale; double font_scale_x; // x scale applied to all glyphs to preserve text aspect ratio double border_scale; + double blur_scale; RenderContext state; TextInfo text_info; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_shaper.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_shaper.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_shaper.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_shaper.c 2014-03-12 06:15:23.000000000 +0000 @@ -18,8 +18,6 @@ #include "config.h" -#include - #include "ass_shaper.h" #include "ass_render.h" #include "ass_font.h" @@ -203,6 +201,12 @@ return NULL; memcpy(&new_val.metrics, &face->glyph->metrics, sizeof(FT_Glyph_Metrics)); + + // if @font rendering is enabled and the glyph should be rotated, + // make cached_h_advance pick up the right advance later + if (metrics->vertical && glyph >= VERTICAL_LOWER_BOUND) + new_val.metrics.horiAdvance = new_val.metrics.vertAdvance; + val = ass_cache_put(metrics->metrics_cache, &metrics->hash_key, &new_val); } @@ -234,9 +238,6 @@ if (!metrics) return 0; - if (metrics_priv->vertical && glyph > VERTICAL_LOWER_BOUND) - return metrics->metrics.vertAdvance; - return metrics->metrics.horiAdvance; } @@ -391,9 +392,7 @@ font->faces[info->face_index], NULL); } - // XXX: this is a rather crude hack - const double ft_size = 256.0; - ass_face_set_size(font->faces[info->face_index], ft_size); + ass_face_set_size(font->faces[info->face_index], info->font_size); update_hb_size(hb_fonts[info->face_index], font->faces[info->face_index]); // update hash key for cached metrics @@ -409,6 +408,107 @@ } /** + * \brief Map script to default language. + * + * This maps a script to a language, if a script has a representative + * language it is typically used with. Otherwise, the invalid language + * is returned. + * + * The mapping is similar to Pango's pango-language.c. + * + * \param script script tag + * \return language tag + */ +static hb_language_t script_to_language(hb_script_t script) +{ + switch (script) { + // Unicode 1.1 + case HB_SCRIPT_ARABIC: return hb_language_from_string("ar", -1); break; + case HB_SCRIPT_ARMENIAN: return hb_language_from_string("hy", -1); break; + case HB_SCRIPT_BENGALI: return hb_language_from_string("bn", -1); break; + case HB_SCRIPT_CANADIAN_ABORIGINAL: return hb_language_from_string("iu", -1); break; + case HB_SCRIPT_CHEROKEE: return hb_language_from_string("chr", -1); break; + case HB_SCRIPT_COPTIC: return hb_language_from_string("cop", -1); break; + case HB_SCRIPT_CYRILLIC: return hb_language_from_string("ru", -1); break; + case HB_SCRIPT_DEVANAGARI: return hb_language_from_string("hi", -1); break; + case HB_SCRIPT_GEORGIAN: return hb_language_from_string("ka", -1); break; + case HB_SCRIPT_GREEK: return hb_language_from_string("el", -1); break; + case HB_SCRIPT_GUJARATI: return hb_language_from_string("gu", -1); break; + case HB_SCRIPT_GURMUKHI: return hb_language_from_string("pa", -1); break; + case HB_SCRIPT_HANGUL: return hb_language_from_string("ko", -1); break; + case HB_SCRIPT_HEBREW: return hb_language_from_string("he", -1); break; + case HB_SCRIPT_HIRAGANA: return hb_language_from_string("ja", -1); break; + case HB_SCRIPT_KANNADA: return hb_language_from_string("kn", -1); break; + case HB_SCRIPT_KATAKANA: return hb_language_from_string("ja", -1); break; + case HB_SCRIPT_LAO: return hb_language_from_string("lo", -1); break; + case HB_SCRIPT_LATIN: return hb_language_from_string("en", -1); break; + case HB_SCRIPT_MALAYALAM: return hb_language_from_string("ml", -1); break; + case HB_SCRIPT_MONGOLIAN: return hb_language_from_string("mn", -1); break; + case HB_SCRIPT_ORIYA: return hb_language_from_string("or", -1); break; + case HB_SCRIPT_SYRIAC: return hb_language_from_string("syr", -1); break; + case HB_SCRIPT_TAMIL: return hb_language_from_string("ta", -1); break; + case HB_SCRIPT_TELUGU: return hb_language_from_string("te", -1); break; + case HB_SCRIPT_THAI: return hb_language_from_string("th", -1); break; + + // Unicode 2.0 + case HB_SCRIPT_TIBETAN: return hb_language_from_string("bo", -1); break; + + // Unicode 3.0 + case HB_SCRIPT_ETHIOPIC: return hb_language_from_string("am", -1); break; + case HB_SCRIPT_KHMER: return hb_language_from_string("km", -1); break; + case HB_SCRIPT_MYANMAR: return hb_language_from_string("my", -1); break; + case HB_SCRIPT_SINHALA: return hb_language_from_string("si", -1); break; + case HB_SCRIPT_THAANA: return hb_language_from_string("dv", -1); break; + + // Unicode 3.2 + case HB_SCRIPT_BUHID: return hb_language_from_string("bku", -1); break; + case HB_SCRIPT_HANUNOO: return hb_language_from_string("hnn", -1); break; + case HB_SCRIPT_TAGALOG: return hb_language_from_string("tl", -1); break; + case HB_SCRIPT_TAGBANWA: return hb_language_from_string("tbw", -1); break; + + // Unicode 4.0 + case HB_SCRIPT_UGARITIC: return hb_language_from_string("uga", -1); break; + + // Unicode 4.1 + case HB_SCRIPT_BUGINESE: return hb_language_from_string("bug", -1); break; + case HB_SCRIPT_OLD_PERSIAN: return hb_language_from_string("peo", -1); break; + case HB_SCRIPT_SYLOTI_NAGRI: return hb_language_from_string("syl", -1); break; + + // Unicode 5.0 + case HB_SCRIPT_NKO: return hb_language_from_string("nko", -1); break; + + // no representative language exists + default: return HB_LANGUAGE_INVALID; break; + } +} + +/** + * \brief Determine language to be used for shaping a run. + * + * \param shaper shaper instance + * \param script script tag associated with run + * \return language tag + */ +static hb_language_t +hb_shaper_get_run_language(ASS_Shaper *shaper, hb_script_t script) +{ + hb_language_t lang; + + // override set, use it + if (shaper->language != HB_LANGUAGE_INVALID) + return shaper->language; + + // get default language for given script + lang = script_to_language(script); + + // no dice, use system default + if (lang == HB_LANGUAGE_INVALID) + lang = hb_language_get_default(); + + return lang; +} + +/** * \brief Shape event text with HarfBuzz. Full OpenType shaping. * \param glyphs glyph clusters * \param len number of clusters @@ -423,13 +523,13 @@ hb_buffer_t *buf; hb_font_t *font; } runs[MAX_RUNS]; - const double ft_size = 256.0; for (i = 0; i < len && run < MAX_RUNS; i++, run++) { // get length and level of the current run int k = i; int level = glyphs[i].shape_run_id; int direction = shaper->emblevels[k] % 2; + hb_script_t script = glyphs[i].script; while (i < (len - 1) && level == glyphs[i+1].shape_run_id) i++; runs[run].offset = k; @@ -440,7 +540,9 @@ hb_buffer_pre_allocate(runs[run].buf, i - k + 1); hb_buffer_set_direction(runs[run].buf, direction ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); - hb_buffer_set_language(runs[run].buf, shaper->language); + hb_buffer_set_language(runs[run].buf, + hb_shaper_get_run_language(shaper, script)); + hb_buffer_set_script(runs[run].buf, script); hb_buffer_add_utf32(runs[run].buf, shaper->event_text + k, i - k + 1, 0, i - k + 1); hb_shape(runs[run].font, runs[run].buf, shaper->features, @@ -476,10 +578,10 @@ // set position and advance info->skip = 0; info->glyph_index = glyph_info[j].codepoint; - info->offset.x = pos[j].x_offset * info->scale_x * (info->font_size / ft_size); - info->offset.y = -pos[j].y_offset * info->scale_y * (info->font_size / ft_size); - info->advance.x = pos[j].x_advance * info->scale_x * (info->font_size / ft_size); - info->advance.y = -pos[j].y_advance * info->scale_y * (info->font_size / ft_size); + info->offset.x = pos[j].x_offset * info->scale_x; + info->offset.y = -pos[j].y_offset * info->scale_y; + info->advance.x = pos[j].x_advance * info->scale_x; + info->advance.y = -pos[j].y_advance * info->scale_y; // accumulate advance in the root glyph root->cluster_advance.x += info->advance.x; @@ -493,6 +595,56 @@ } } + +/** + * \brief Determine script property of all characters. Characters of script + * common and inherited get their script from their context. + * + */ +void ass_shaper_determine_script(ASS_Shaper *shaper, GlyphInfo *glyphs, + size_t len) +{ + int i; + int backwards_scan = 0; + hb_unicode_funcs_t *ufuncs = hb_unicode_funcs_get_default(); + hb_script_t last_script = HB_SCRIPT_UNKNOWN; + + // determine script (forward scan) + for (i = 0; i < len; i++) { + GlyphInfo *info = glyphs + i; + info->script = hb_unicode_script(ufuncs, info->symbol); + + // common/inherit codepoints inherit script from context + if (info->script == HB_SCRIPT_COMMON || + info->script == HB_SCRIPT_INHERITED) { + // unknown is not a valid context + if (last_script != HB_SCRIPT_UNKNOWN) + info->script = last_script; + else + // do a backwards scan to check if next codepoint + // contains a valid script for context + backwards_scan = 1; + } else { + last_script = info->script; + } + } + + // determine script (backwards scan, if needed) + last_script = HB_SCRIPT_UNKNOWN; + for (i = len - 1; i >= 0 && backwards_scan; i--) { + GlyphInfo *info = glyphs + i; + + // common/inherit codepoints inherit script from context + if (info->script == HB_SCRIPT_COMMON || + info->script == HB_SCRIPT_INHERITED) { + // unknown script is not a valid context + if (last_script != HB_SCRIPT_UNKNOWN) + info->script = last_script; + } else { + last_script = info->script; + } + } +} #endif /** @@ -543,6 +695,11 @@ int i; int shape_run = 0; +#ifdef CONFIG_HARFBUZZ + ass_shaper_determine_script(shaper, glyphs, len); +#endif + + // find appropriate fonts for the shape runs for (i = 0; i < len; i++) { GlyphInfo *last = glyphs + i - 1; GlyphInfo *info = glyphs + i; @@ -555,11 +712,13 @@ // shape runs share the same font face and size if (i > 0 && (last->font != info->font || last->font_size != info->font_size || - last->face_index != info->face_index)) + last->scale_x != info->scale_x || + last->scale_y != info->scale_y || + last->face_index != info->face_index || + last->script != info->script)) shape_run++; info->shape_run_id = shape_run; } - } /** @@ -579,7 +738,14 @@ void ass_shaper_set_language(ASS_Shaper *shaper, const char *code) { #ifdef CONFIG_HARFBUZZ - shaper->language = hb_language_from_string(code, -1); + hb_language_t lang; + + if (code) + lang = hb_language_from_string(code, -1); + else + lang = HB_LANGUAGE_INVALID; + + shaper->language = lang; #endif } @@ -715,10 +881,9 @@ // Create reorder map line-by-line for (i = 0; i < text_info->n_lines; i++) { LineInfo *line = text_info->lines + i; - int level; FriBidiParType dir = FRIBIDI_PAR_ON; - level = fribidi_reorder_line(0, + fribidi_reorder_line(0, shaper->ctypes + line->offset, line->len, 0, dir, shaper->emblevels + line->offset, NULL, shaper->cmap + line->offset); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_shaper.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_shaper.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_shaper.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_shaper.h 2014-03-12 06:15:23.000000000 +0000 @@ -21,7 +21,7 @@ #include "config.h" -#include +#include #include "ass_render.h" void ass_shaper_info(ASS_Library *lib); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_types.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_types.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_types.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_types.h 2014-03-12 06:15:23.000000000 +0000 @@ -50,7 +50,7 @@ double ScaleX; double ScaleY; double Spacing; - int Angle; + double Angle; int BorderStyle; double Outline; double Shadow; @@ -60,6 +60,7 @@ int MarginV; int Encoding; int treat_fontname_as_pattern; + double Blur; } ASS_Style; /* @@ -83,6 +84,72 @@ ASS_RenderPriv *render_priv; } ASS_Event; +/** + * Support for (xy-)vsfilter mangled colors + * + * Generally, xy-vsfilter emulates the classic vsfilter behavior of + * rendering directly into the (usually YCbCr) video. vsfilter is + * hardcoded to use BT.601(TV) as target colorspace when converting + * the subtitle RGB color to the video colorspace. This led to major + * breakage when HDTV video was introduced: HDTV typically uses + * BT.709(TV), but vsfilter still used BT.601(TV) for conversion. + * + * This means classic vsfilter will mangle colors as follows: + * + * screen_rgb = bt_709tv_to_rgb(rgb_to_bt601tv(ass_rgb)) + * + * Or in general: + * + * screen_rgb = video_csp_to_rgb(rgb_to_bt601tv(ass_rgb)) + * + * where video_csp is the colorspace of the video with which the + * subtitle was muxed. + * + * xy-vsfilter did not fix this, but instead introduced explicit + * rules how colors were mangled by adding a "YCbCr Matrix" header. + * If this header specifies a real colorspace (like BT.601(TV) etc.), + * xy-vsfilter behaves exactly like vsfilter, but using the specified + * colorspace for conversion of ASS input RGB to screen RGB: + * + * screen_rgb = video_csp_to_rgb(rgb_to_ycbcr_header_csp(ass_rgb)) + * + * Further, xy-vsfilter behaves like vsfilter with no changes if the header + * is missing. + * + * The special value "None" means untouched RGB values. Keep in mind that + * some version of xy-vsfilter are buggy and don't interpret this correctly. + * It appears some people are advocating that this header value is + * intended for situations where exact colors do not matter. + * + * Note that newer Aegisub versions (the main application to produce ASS + * subtitle scripts) have an option that tries not to mangle the colors. It + * is said that if the header is not set to BT.601(TV), the colors are + * supposed not to be mangled, even if the "YCbCr Matrix" header is not + * set to "None". In other words, the video colorspace as detected by + * Aegisub is the same as identified in the file header. + * + * In general, misinterpreting this header or not using it will lead to + * slightly different subtitle colors, which can matter if the subtitle + * attempts to match solid colored areas in the video. + * + * Note that libass doesn't change colors based on this header. It + * absolutely can't do that, because the video colorspace is required + * in order to handle this as intended by xy-vsfilter. + */ +typedef enum ASS_YCbCrMatrix { + YCBCR_DEFAULT = 0, // Header missing + YCBCR_UNKNOWN, // Header could not be parsed correctly + YCBCR_NONE, // "None" special value + YCBCR_BT601_TV, + YCBCR_BT601_PC, + YCBCR_BT709_TV, + YCBCR_BT709_PC, + YCBCR_SMPTE240M_TV, + YCBCR_SMPTE240M_PC, + YCBCR_FCC_TV, + YCBCR_FCC_PC +} ASS_YCbCrMatrix; + /* * ass track represent either an external script or a matroska subtitle stream * (no real difference between them); it can be used in rendering after the @@ -113,6 +180,7 @@ int ScaledBorderAndShadow; int Kerning; char *Language; + ASS_YCbCrMatrix YCbCrMatrix; int default_style; // index of default style char *name; // file name in case of external subs, 0 for streams diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_utils.c avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_utils.c --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_utils.c 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_utils.c 2014-03-12 06:15:23.000000000 +0000 @@ -122,6 +122,46 @@ return 0; } +int parse_ycbcr_matrix(char *str) +{ + while (*str == ' ' || *str == '\t') + str++; + if (*str == '\0') + return YCBCR_DEFAULT; + + char *end = str + strlen(str); + while (end[-1] == ' ' || end[-1] == '\t') + end--; + + // Trim a local copy of the input that we know is safe to + // modify. The buffer is larger than any valid string + NUL, + // so we can simply chop off the rest of the input. + char buffer[16]; + size_t n = FFMIN(end - str, sizeof buffer - 1); + strncpy(buffer, str, n); + buffer[n] = '\0'; + + if (!strcasecmp(buffer, "none")) + return YCBCR_NONE; + if (!strcasecmp(buffer, "tv.601")) + return YCBCR_BT601_TV; + if (!strcasecmp(buffer, "pc.601")) + return YCBCR_BT601_PC; + if (!strcasecmp(buffer, "tv.709")) + return YCBCR_BT709_TV; + if (!strcasecmp(buffer, "pc.709")) + return YCBCR_BT709_PC; + if (!strcasecmp(buffer, "tv.240m")) + return YCBCR_SMPTE240M_TV; + if (!strcasecmp(buffer, "pc.240m")) + return YCBCR_SMPTE240M_PC; + if (!strcasecmp(buffer, "tv.fcc")) + return YCBCR_FCC_TV; + if (!strcasecmp(buffer, "pc.fcc")) + return YCBCR_FCC_PC; + return YCBCR_UNKNOWN; +} + void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...) { va_list va; @@ -165,14 +205,20 @@ * \param track track * \param name style name * \return index in track->styles - * Returnes 0 if no styles found => expects at least 1 style. - * Parsing code always adds "Default" style in the end. + * Returns 0 if no styles found => expects at least 1 style. + * Parsing code always adds "Default" style in the beginning. */ int lookup_style(ASS_Track *track, char *name) { int i; - if (*name == '*') - ++name; // FIXME: what does '*' really mean ? + // '*' seem to mean literally nothing; + // VSFilter removes them as soon as it can + while (*name == '*') + ++name; + // VSFilter then normalizes the case of "Default" + // (only in contexts where this function is called) + if (strcasecmp(name, "Default") == 0) + name = "Default"; for (i = track->n_styles - 1; i >= 0; --i) { if (strcmp(track->styles[i].Name, name) == 0) return i; @@ -181,7 +227,27 @@ ass_msg(track->library, MSGL_WARN, "[%p]: Warning: no style named '%s' found, using '%s'", track, name, track->styles[i].Name); - return i; // use the first style + return i; +} + +/** + * \brief find style by name as in \r + * \param track track + * \param name style name + * \return style in track->styles + * Returns NULL if no style has the given name. + */ +ASS_Style *lookup_style_strict(ASS_Track *track, char *name) +{ + int i; + for (i = track->n_styles - 1; i >= 0; --i) { + if (strcmp(track->styles[i].Name, name) == 0) + return track->styles + i; + } + ass_msg(track->library, MSGL_WARN, + "[%p]: Warning: no style named '%s' found", + track, name); + return NULL; } #ifdef CONFIG_ENCA diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_utils.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_utils.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_utils.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/ass_utils.h 2014-03-12 06:15:23.000000000 +0000 @@ -49,9 +49,11 @@ int mystrtod(char **p, double *res); int strtocolor(ASS_Library *library, char **q, uint32_t *res, int hex); char parse_bool(char *str); +int parse_ycbcr_matrix(char *str); unsigned ass_utf8_get_char(char **str); void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...); int lookup_style(ASS_Track *track, char *name); +ASS_Style *lookup_style_strict(ASS_Track *track, char *name); #ifdef CONFIG_ENCA void *ass_guess_buffer_cp(ASS_Library *library, unsigned char *buffer, int buflen, char *preferred_language, diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/libass.sym avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/libass.sym --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/libass.sym 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/libass.sym 2014-03-12 06:15:23.000000000 +0000 @@ -6,6 +6,7 @@ ass_renderer_init ass_renderer_done ass_set_frame_size +ass_set_storage_size ass_set_margins ass_set_use_margins ass_set_aspect_ratio @@ -36,3 +37,4 @@ ass_flush_events ass_set_shaper ass_set_line_position +ass_set_pixel_aspect diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/Makefile.am avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/Makefile.am --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/Makefile.am 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/Makefile.am 2014-03-12 06:15:23.000000000 +0000 @@ -2,7 +2,7 @@ LIBASS_LT_CURRENT = 5 LIBASS_LT_REVISION = 0 -LIBASS_LT_AGE = 1 +LIBASS_LT_AGE = 0 lib_LTLIBRARIES = libass.la libass_la_SOURCES = ass.c ass_cache.c ass_font.c ass_fontconfig.c ass_render.c \ @@ -12,7 +12,7 @@ ass_drawing.h ass_cache_template.h ass_render.h \ ass_parse.c ass_parse.h ass_render_api.c ass_shaper.c \ ass_shaper.h ass_strtod.c -libass_la_LDFLAGS = -version-info $(LIBASS_LT_CURRENT):$(LIBASS_LT_REVISION):$(LIBASS_LT_AGE) +libass_la_LDFLAGS = -no-undefined -version-info $(LIBASS_LT_CURRENT):$(LIBASS_LT_REVISION):$(LIBASS_LT_AGE) libass_la_LDFLAGS += -export-symbols $(srcdir)/libass.sym assheadersdir = $(includedir)/ass diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/Makefile.in avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/Makefile.in --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/Makefile.in 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_libass/Makefile.in 2014-03-12 06:15:23.000000000 +0000 @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -17,6 +17,23 @@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -70,6 +87,12 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(assheadersdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libass_la_LIBADD = @@ -78,8 +101,8 @@ ass_library.lo ass_drawing.lo ass_parse.lo ass_render_api.lo \ ass_shaper.lo ass_strtod.lo libass_la_OBJECTS = $(am_libass_la_OBJECTS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent libass_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -94,24 +117,29 @@ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_$(V)) -am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_$(V)) -am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libass_la_SOURCES) DIST_SOURCES = $(libass_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac HEADERS = $(dist_assheaders_HEADERS) ETAGS = etags CTAGS = ctags @@ -132,6 +160,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -167,6 +196,7 @@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -183,6 +213,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PKG_LIBS_DEFAULT = @PKG_LIBS_DEFAULT@ PKG_LIBS_PRIVATE = @PKG_LIBS_PRIVATE@ PKG_REQUIRES_DEFAULT = @PKG_REQUIRES_DEFAULT@ @@ -197,6 +229,7 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -229,7 +262,6 @@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -248,7 +280,7 @@ AM_CFLAGS = -Wall LIBASS_LT_CURRENT = 5 LIBASS_LT_REVISION = 0 -LIBASS_LT_AGE = 1 +LIBASS_LT_AGE = 0 lib_LTLIBRARIES = libass.la libass_la_SOURCES = ass.c ass_cache.c ass_font.c ass_fontconfig.c ass_render.c \ ass_utils.c ass_bitmap.c ass_library.c ass_bitmap.h \ @@ -258,7 +290,7 @@ ass_parse.c ass_parse.h ass_render_api.c ass_shaper.c \ ass_shaper.h ass_strtod.c -libass_la_LDFLAGS = -version-info \ +libass_la_LDFLAGS = -no-undefined -version-info \ $(LIBASS_LT_CURRENT):$(LIBASS_LT_REVISION):$(LIBASS_LT_AGE) \ -export-symbols $(srcdir)/libass.sym assheadersdir = $(includedir)/ass @@ -300,7 +332,6 @@ $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ @@ -308,6 +339,8 @@ else :; fi; \ done; \ test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } @@ -329,7 +362,7 @@ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done -libass.la: $(libass_la_OBJECTS) $(libass_la_DEPENDENCIES) +libass.la: $(libass_la_OBJECTS) $(libass_la_DEPENDENCIES) $(EXTRA_libass_la_DEPENDENCIES) $(AM_V_CCLD)$(libass_la_LINK) -rpath $(libdir) $(libass_la_OBJECTS) $(libass_la_LIBADD) $(LIBS) mostlyclean-compile: @@ -355,26 +388,23 @@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo @@ -383,8 +413,11 @@ -rm -rf .libs _libs install-dist_assheadersHEADERS: $(dist_assheaders_HEADERS) @$(NORMAL_INSTALL) - test -z "$(assheadersdir)" || $(MKDIR_P) "$(DESTDIR)$(assheadersdir)" @list='$(dist_assheaders_HEADERS)'; test -n "$(assheadersdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(assheadersdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(assheadersdir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -398,9 +431,7 @@ @$(NORMAL_UNINSTALL) @list='$(dist_assheaders_HEADERS)'; test -n "$(assheadersdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(assheadersdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(assheadersdir)" && rm -f $$files + dir='$(DESTDIR)$(assheadersdir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -501,10 +532,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_vidASS.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_vidASS.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/ADM_vidASS.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/ADM_vidASS.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -20,6 +20,7 @@ #include "ass_ssa.h" #include "ass_ssa_desc.cpp" +#include "ADM_coreSubtitles/inc/ADM_coreSubtitles.h" extern "C" { @@ -53,12 +54,12 @@ // Add the hook to make it valid plugin DECLARE_VIDEO_FILTER( subAss, // Class - 1,0,0, // Version + 1,0,1, // Version ADM_UI_ALL, // UI VF_SUBTITLE, // Category "ssa", // internal name (must be uniq!) - QT_TRANSLATE_NOOP("ass","SSA."), // Display name - QT_TRANSLATE_NOOP("ass","Hardcode ass/ssa subtitles using libass.") // Description + QT_TRANSLATE_NOOP("ass","SSA/ASS/SRT"), // Display name + QT_TRANSLATE_NOOP("ass","Hardcode ass/ssa/srt subtitles using libass.") // Description ); @@ -101,30 +102,26 @@ /** \fn ctor */ -subAss::subAss( ADM_coreVideoFilter *in,CONFcouple *setup) : ADM_coreVideoFilter(in,setup) -{ - if(!setup || !ADM_paramLoad(setup,ass_ssa_param,¶m)) - { - param.font_scale = 1.; - param.line_spacing = param.topMargin = param.bottomMargin = 0; - param.subtitleFile = NULL; - param.fontDirectory = ADM_strdup(DEFAULT_FONT_DIR); - param.extractEmbeddedFonts = 1; +subAss::subAss( ADM_coreVideoFilter *in,CONFcouple *setup) : ADM_coreVideoFilter(in,setup) { + if (!setup || !ADM_paramLoad(setup, ass_ssa_param, ¶m)) { + param.font_scale = 1.; + param.line_spacing = param.topMargin = param.bottomMargin = 0; + param.subtitleFile = NULL; + param.fontDirectory = ADM_strdup(DEFAULT_FONT_DIR); + param.extractEmbeddedFonts = 1; } - src=new ADMImageDefault(in->getInfo()->width,in->getInfo()->height); + src = new ADMImageDefault(in->getInfo()->width, in->getInfo()->height); - /* ASS initialization */ - _ass_lib = NULL; - _ass_track = NULL; - _ass_rend = NULL; - - if(param.subtitleFile) - { - if(!this->setup()) - { - GUI_Error_HIG("Format ?","Are you sure this is an ass file ?"); - } + /* ASS initialization */ + _ass_lib = NULL; + _ass_track = NULL; + _ass_rend = NULL; + + if (param.subtitleFile) { + if (!this->setup()) { + GUI_Error_HIG("Format ?", "Are you sure this is an ass file ?"); } + } } /** \fn dtor @@ -166,6 +163,7 @@ MKME(scale,font_scale); MKME(spacing,line_spacing); + char newName[2*1024]; // should be a dynamic size.. diaElemFile file(0,(char **)PX(subtitleFile),QT_TRANSLATE_NOOP("ass","_Subtitle file (ASS/SSA):"), NULL, QT_TRANSLATE_NOOP("ass","Select Subtitle file")); diaElemFloat dSpacing(&spacing,QT_TRANSLATE_NOOP("ass","_Line spacing:"),0.10,10.0); @@ -174,9 +172,41 @@ diaElemUInteger dBottom(PX(bottomMargin),QT_TRANSLATE_NOOP("ass","Botto_m margin"),0,200); diaElem *elems[5]={&file,&dSpacing,&dScale,&dTop,&dBottom}; - +again: if( diaFactoryRun(QT_TRANSLATE_NOOP("ass","ASS"),5,elems)) { + char *p=param.subtitleFile; + int l=strlen(p); + if(l>3 && !strcasecmp(p+l-4,".srt")) + { + if(!GUI_Question("This is a srt file. Convert to SSA ?")) + { + goto again; + } + ADM_subtitle sub; + if(!sub.load(p)) + { + GUI_Error_HIG("Error","Cannot load this srt file."); + goto again; + } + if(false==sub.srt2ssa()) + { + GUI_Error_HIG("Error","Cannot convert to ssa."); + goto again; + } + + strcpy(newName,p); + strcpy(newName+l-4,".ssa"); + if(false==sub.saveAsSSA(newName)) + { + GUI_Error_HIG("Error","Cannot save converted file."); + goto again; + } + // all ok, we can now use the ssa file + strcpy(p,newName); + } + + #undef MKME #define MKME(x,y) param.y=(float)x MKME(scale,font_scale); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/CMakeLists.txt avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/CMakeLists.txt --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/ass/CMakeLists.txt 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/ass/CMakeLists.txt 2014-03-12 06:15:23.000000000 +0000 @@ -12,7 +12,7 @@ ADD_VIDEO_FILTER(ADM_vf_ssa ${ADM_vf_ssa_SRCS}) IF(DO_COMMON) - TARGET_LINK_LIBRARIES(ADM_vf_ssa ADM_libass ${FREETYPE2_LDFLAGS} ${FRIDIBI_LDFLAGS}) + TARGET_LINK_LIBRARIES(ADM_vf_ssa ADM_libass ${FREETYPE2_LDFLAGS} ${FRIDIBI_LDFLAGS} ADM_coreSubtitle) # We force the use of fontconfig ADD_DEFINITIONS("-DUSE_FONTCONFIG") TARGET_LINK_LIBRARIES(ADM_vf_ssa ${FONTCONFIG_LDFLAGS}) diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/avsfilter/avsfilter.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/avsfilter/avsfilter.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/avsfilter/avsfilter.cpp 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/avsfilter/avsfilter.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -43,9 +43,12 @@ #include "avsfilter.h" #include "cdebug.h" -#define AVSFILTER_VERSION_INFO "AvsFilter, ver 0.10" +#define AVSFILTER_VERSION_INFO "AvsFilter, ver 0.12" #define NOCOMPILE26 +bool use_adv_protocol_avsfilter_to_pipesource = false; +bool use_adv_protocol_avsloader_to_avsfilter = false; + static WINE_LOADER *first_loader = NULL; static AVSTerminate term; @@ -256,8 +259,7 @@ sz1 = read(hr, &test_r1, sizeof(uint32_t)); - if (sz1 != sizeof(uint32_t) || - test_r1 != test_send) return false; + if (sz1 != sizeof(uint32_t) || (test_r1 != test_send)) return false; return true; } @@ -417,7 +419,7 @@ DEBUG_PRINTF("avsfilter : test pipe to loader ok\n"); } else - goto error_pipe_test; + goto error_pipe_test; } else { @@ -432,7 +434,7 @@ } bool avs_start(FilterInfo *info, FilterInfo *avisynth_info, - char *fname, AVS_PIPES *avs_pipes) + char *fname, AVS_PIPES *avs_pipes, PITCH_DATA *pd_pipe_source, PITCH_DATA *pd_avsloader) { DEBUG_PRINTF("avsfilter : avs_start()\n"); DEBUG_PRINTF("avsfilter : %X %X %s %X\n", @@ -446,7 +448,7 @@ aii.width = info->width; aii.height = info->height; aii.nb_frames = info->totalDuration / info->frameIncrement; - aii.encoding = 1; + aii.encoding = MAGIC_ADV_PROTOCOL_VAL; aii.codec = 0; aii.fps1000 = ADM_Fps1000FromUs(info->frameIncrement); aii.orgFrame = 0; @@ -464,23 +466,62 @@ } // get avisynth frame info - PIPE_MSG_HEADER msg; - if (!receive_cmd(avs_pipes[PIPE_LOADER_READ].hpipe, - &msg) || - msg.avs_cmd != SET_CLIP_PARAMETER || - !receive_data(avs_pipes[PIPE_LOADER_READ].hpipe, - &msg, &aio)) - { - DEBUG_PRINTF_RED("avsfilter : cannot receive avisynth clip parameters\n"); - deinit_pipes(avs_pipes, CMD_PIPE_NUM); - return false; - } + PIPE_MSG_HEADER msg; + if (!receive_cmd(avs_pipes[PIPE_LOADER_READ].hpipe, &msg)) + { + DEBUG_PRINTF_RED("avsfilter : cannot receive command (SEND_PITCH_DATA_PIPE_SOURCE, OR SET_CLIP_PARAMETER)\n"); + deinit_pipes(avs_pipes, CMD_PIPE_NUM); + return false; + } + + switch (msg.avs_cmd) + { + case SEND_PITCH_DATA_PIPE_SOURCE: + if (!receive_data(avs_pipes[PIPE_LOADER_READ].hpipe, &msg, pd_pipe_source)) + { + DEBUG_PRINTF_RED("avsfilter : cannot receive SEND_PITCH_DATA_PIPE_SOURCE\n"); + deinit_pipes(avs_pipes, CMD_PIPE_NUM); + return false; + } + DEBUG_PRINTF("avsfilter : receive SEND_PITCH_DATA_PIPE_SOURCE YUV = %d %d %d\n", pd_pipe_source->pitchY, pd_pipe_source->pitchU, pd_pipe_source->pitchV); + if (!receive_cmd(avs_pipes[PIPE_LOADER_READ].hpipe, &msg) || + msg.avs_cmd != SET_CLIP_PARAMETER) + { + DEBUG_PRINTF_RED("avsfilter : cannot receive SET_CLIP_PARAMETER header message\n"); + deinit_pipes(avs_pipes, CMD_PIPE_NUM); + return false; + } + case SET_CLIP_PARAMETER: + if (!receive_data(avs_pipes[PIPE_LOADER_READ].hpipe, &msg, &aio)) + { + DEBUG_PRINTF_RED("avsfilter : cannot receive avisynth clip parameters\n"); + deinit_pipes(avs_pipes, CMD_PIPE_NUM); + return false; + } + break; + default : + DEBUG_PRINTF_RED("avsfilter : receive unknown command %d\n", msg.avs_cmd); + deinit_pipes(avs_pipes, CMD_PIPE_NUM); + return false; + break; + } DEBUG_PRINTF("avsfilter : receive ADV_Info from avsloader [fps1000 = %d, nb_frames = %d]\n", aio.fps1000, aio.nb_frames); avisynth_info->width = aio.width; avisynth_info->height = aio.height; avisynth_info->frameIncrement = ADM_UsecFromFps1000(aio.fps1000); avisynth_info->totalDuration = aio.nb_frames * avisynth_info->frameIncrement; + if (aio.encoding == MAGIC_ADV_PROTOCOL_VAL) + { + DEBUG_PRINTF("avsfilter : send GET_PITCH_DATA to avsloader\n"); + if (!send_cmd(avs_pipes[PIPE_LOADER_WRITE].hpipe, + GET_PITCH_DATA, NULL, 0)) + { + DEBUG_PRINTF_RED("avsfilter : cannot send GET_PITCH_DATA\n"); + deinit_pipes(avs_pipes, CMD_PIPE_NUM); + return false; + } + } // correct avisynth_info for span of frames, calculate fps change metrics /* float k_fps; @@ -495,7 +536,7 @@ #ifdef VERSION_2_5 DECLARE_VIDEO_FILTER(avsfilter, - 0,0,10, + 0,0,12, ADM_UI_ALL, VF_MISC, "avsfilter", @@ -650,7 +691,7 @@ DEBUG_PRINTF("avsfilter : SetParameters !full_exact\n"); // matched only order (need reload with new script/geometry/etc) - if (!avs_start(&info, &loader->output_info, (char*)newparam->avs_script, loader->avs_pipes)) + if (!avs_start(&info, &loader->output_info, (char*)newparam->avs_script, loader->avs_pipes, &pd_pipe_source, &pd_avsloader)) { DEBUG_PRINTF_RED("avsfilter : SetParameters fail avs_start\n"); delete_object(loader); @@ -792,6 +833,14 @@ DEBUG_PRINTF("avsfilter : after constructor info : frameIncrement %lu totalDuration %llu\n", info.frameIncrement, info.totalDuration); + if (_uncompressed->GetPitch(PLANAR_Y) == pd_pipe_source.pitchY && + _uncompressed->GetPitch(PLANAR_U) == pd_pipe_source.pitchU && + _uncompressed->GetPitch(PLANAR_V) == pd_pipe_source.pitchV) + { + use_adv_protocol_avsfilter_to_pipesource = true; + DEBUG_PRINTF("avsfilter : use_adv_protocol_avsfilter_to_pipesource = true\n"); + } + // vidCache=new VideoCache(16,in); } @@ -830,7 +879,7 @@ DEBUG_PRINTF("avsfilter : getCoupledConf info #2: frameIncrement %lu totalDuration %llu\n", info.frameIncrement, info.totalDuration); return t; - + /* CSET(wine_app); CSET(avs_script); CSET(avs_loader); @@ -897,7 +946,7 @@ // send command to get filtered data if (!send_cmd(wine_loader->avs_pipes[PIPE_LOADER_WRITE].hpipe, - GET_FRAME, (void*)&fd, + use_adv_protocol_avsloader_to_avsfilter ? GET_FRAME_WITH_PITCH : GET_FRAME, (void*)&fd, sizeof(FRAME_DATA))) { DEBUG_PRINTF_RED("avsfilter : error send GET_FRAME to avsloader\n"); @@ -906,11 +955,27 @@ // read all data from avsloader and pipe dll PIPE_MSG_HEADER msg; - while (receive_cmd(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, - &msg)) + while (receive_cmd(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, &msg)) { switch(msg.avs_cmd) { + case SEND_PITCH_DATA_AVSLOADER: + DEBUG_PRINTF("avsfilter : receive SEND_PITCH_DATA_AVSLOADER\n"); + if (!receive_data(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, &msg, &pd_avsloader)) + { + DEBUG_PRINTF_RED("avsfilter : cannot get SEND_PITCH_DATA_AVSLOADER\n"); + return 0; + } + DEBUG_PRINTF("avsfilter : receive SEND_PITCH_DATA_AVSLOADER YUV = %d %d %d\n", pd_avsloader.pitchY, pd_avsloader.pitchU, pd_avsloader.pitchV); + if (data->GetPitch(PLANAR_Y) == pd_avsloader.pitchY && + data->GetPitch(PLANAR_U) == pd_avsloader.pitchU && + data->GetPitch(PLANAR_V) == pd_avsloader.pitchV) + { + use_adv_protocol_avsloader_to_avsfilter = true; + DEBUG_PRINTF("avsfilter : use_adv_protocol_avsloader_to_avsfilter = true\n"); + } + break; + case GET_FRAME: // this request from pipe_source for input frame(s) to avisynth core DEBUG_PRINTF("avsfilter : receive GET_FRAME\n"); if (!receive_data(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, @@ -929,41 +994,64 @@ DEBUG_PRINTF("avsfilter : !!!OOPS!!!\n"); return false; } - DEBUG_PRINTF("avsfilter : in frame size %lu pitchYUV %d %d %d, widthYUV %d %d %d, heightYUV %d %d %d\n", + +/* DEBUG_PRINTF("avsfilter : in frame size %lu pitchYUV %d %d %d, widthYUV %d %d %d, heightYUV %d %d %d\n", in_frame_sz, _uncompressed->GetPitch(PLANAR_Y), _uncompressed->GetPitch(PLANAR_U), _uncompressed->GetPitch(PLANAR_V), _uncompressed->GetWidth(PLANAR_Y), _uncompressed->GetWidth(PLANAR_U), _uncompressed->GetWidth(PLANAR_V), - _uncompressed->GetHeight(PLANAR_Y), _uncompressed->GetHeight(PLANAR_U), _uncompressed->GetHeight(PLANAR_V)); - // send frame to pipe_source - if (!send_cmd_with_specified_size(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, - PUT_FRAME, (void*)&fd, sizeof(FRAME_DATA), in_frame_sz) || - !send_bit_blt(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, - _uncompressed->GetReadPtr(PLANAR_Y), _uncompressed->GetPitch(PLANAR_Y), - _uncompressed->GetWidth(PLANAR_Y), _uncompressed->GetHeight(PLANAR_Y), tmp_buf) || - !send_bit_blt(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, - _uncompressed->GetReadPtr(PLANAR_U), _uncompressed->GetPitch(PLANAR_U), - _uncompressed->GetWidth(PLANAR_U), _uncompressed->GetHeight(PLANAR_U), tmp_buf) || - !send_bit_blt(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, - _uncompressed->GetReadPtr(PLANAR_V), _uncompressed->GetPitch(PLANAR_V), - _uncompressed->GetWidth(PLANAR_V), _uncompressed->GetHeight(PLANAR_V), tmp_buf)) + _uncompressed->GetHeight(PLANAR_Y), _uncompressed->GetHeight(PLANAR_U), _uncompressed->GetHeight(PLANAR_V));*/ + + if (use_adv_protocol_avsfilter_to_pipesource) { - DEBUG_PRINTF_RED("avsfilter : error send uncompressed frame to dll\n"); + uint32_t pitch_data_sizeY = _uncompressed->GetPitch(PLANAR_Y) * _uncompressed->GetHeight(PLANAR_Y); + uint32_t pitch_data_sizeU = _uncompressed->GetPitch(PLANAR_U) * _uncompressed->GetHeight(PLANAR_U); + uint32_t pitch_data_sizeV = _uncompressed->GetPitch(PLANAR_V) * _uncompressed->GetHeight(PLANAR_V); + uint32_t pitch_data_size = pitch_data_sizeY + pitch_data_sizeU + pitch_data_sizeV; + DEBUG_PRINTF("avsfilter : pitch frame size %lu\n", pitch_data_size); + + if (!send_cmd_with_specified_size(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, + PUT_FRAME_WITH_PITCH, + (void*)&fd, sizeof(FRAME_DATA), pitch_data_size) || + ppwrite(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, _uncompressed->GetReadPtr(PLANAR_Y), pitch_data_sizeY) != pitch_data_sizeY || + ppwrite(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, _uncompressed->GetReadPtr(PLANAR_U), pitch_data_sizeU) != pitch_data_sizeU || + ppwrite(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, _uncompressed->GetReadPtr(PLANAR_V), pitch_data_sizeV) != pitch_data_sizeV) + { + DEBUG_PRINTF_RED("avsfilter : error send uncompressed PITCH frame to dll\n"); return 0; + } } + else + // send frame to pipe_source + if (!send_cmd_with_specified_size(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, + PUT_FRAME, (void*)&fd, sizeof(FRAME_DATA), in_frame_sz) || + !send_bit_blt(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, + _uncompressed->GetReadPtr(PLANAR_Y), _uncompressed->GetPitch(PLANAR_Y), + _uncompressed->GetWidth(PLANAR_Y), _uncompressed->GetHeight(PLANAR_Y), tmp_buf) || + !send_bit_blt(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, + _uncompressed->GetReadPtr(PLANAR_U), _uncompressed->GetPitch(PLANAR_U), + _uncompressed->GetWidth(PLANAR_U), _uncompressed->GetHeight(PLANAR_U), tmp_buf) || + !send_bit_blt(wine_loader->avs_pipes[PIPE_FILTER_WRITE].hpipe, + _uncompressed->GetReadPtr(PLANAR_V), _uncompressed->GetPitch(PLANAR_V), + _uncompressed->GetWidth(PLANAR_V), _uncompressed->GetHeight(PLANAR_V), tmp_buf)) + { + DEBUG_PRINTF_RED("avsfilter : error send uncompressed frame to dll\n"); + return 0; + } //YPLANE(_uncompressed), DEBUG_PRINTF("avsfilter : send data ok for frame %d\n", fd.frame); break; + case PUT_FRAME_WITH_PITCH: case PUT_FRAME: // this request from avsload.exe with filtering data after avisynth - DEBUG_PRINTF("avsfilter : receive PUT_FRAME, msg.sz %d\n", msg.sz); - if (msg.sz != out_frame_sz + sizeof(FRAME_DATA)) + DEBUG_PRINTF("avsfilter : receive %s, msg.sz %d\n", msg.avs_cmd == PUT_FRAME_WITH_PITCH ? "PUT_FRAME_WITH_PITCH" : "PUT_FRAME", msg.sz); + if (msg.avs_cmd == PUT_FRAME && msg.sz != out_frame_sz + sizeof(FRAME_DATA)) { - DEBUG_PRINTF_RED("avsfilter : PUT_FRAME msg.sz [%lu] != out_frame_sz+sizeof(FRAME_DATA) [%lu,%d]\n", - msg.sz, out_frame_sz, sizeof(FRAME_DATA)); + DEBUG_PRINTF_RED("avsfilter : PUT_FRAME error : msg.sz [%d] != out_frame_sz+sizeof(FRAME_DATA) [%d,%d]\n", + msg.sz, out_frame_sz, sizeof(FRAME_DATA)); return 0; } - DEBUG_PRINTF("avsfilter : read 1\n"); +// DEBUG_PRINTF("avsfilter : read 1\n"); if (!receive_data_by_size(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, &fd, sizeof(FRAME_DATA))) { @@ -973,42 +1061,67 @@ // ADM_assert(fd.frame == (iframe + info.orgFrame)); - DEBUG_PRINTF("avsfilter : data->GetWidth(PLANAR_Y) %d data->GetHeight(PLANAR_Y) %d\n", +/* DEBUG_PRINTF("avsfilter : data->GetWidth(PLANAR_Y) %d data->GetHeight(PLANAR_Y) %d\n", data->GetWidth(PLANAR_Y), data->GetHeight(PLANAR_Y)); DEBUG_PRINTF("avsfilter : data->GetWidth(PLANAR_U) %d data->GetHeight(PLANAR_U) %d\n", data->GetWidth(PLANAR_U), data->GetHeight(PLANAR_U)); DEBUG_PRINTF("avsfilter : data->GetWidth(PLANAR_V) %d data->GetHeight(PLANAR_V) %d\n", - data->GetWidth(PLANAR_V), data->GetHeight(PLANAR_V)); + data->GetWidth(PLANAR_V), data->GetHeight(PLANAR_V));*/ - DEBUG_PRINTF("avsfilter : read %d frame number Y plane\n", fd.frame); - if (!receive_bit_blt(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, - data->GetWritePtr(PLANAR_Y), data->GetPitch(PLANAR_Y), - data->GetWidth(PLANAR_Y), data->GetHeight(PLANAR_Y))) + if (msg.avs_cmd == PUT_FRAME_WITH_PITCH) { - DEBUG_PRINTF_RED("avsfilter : receive data error#2\n"); + uint32_t pitch_data_sizeY = data->GetPitch(PLANAR_Y) * data->GetHeight(PLANAR_Y); + uint32_t pitch_data_sizeU = data->GetPitch(PLANAR_U) * data->GetHeight(PLANAR_U); + uint32_t pitch_data_sizeV = data->GetPitch(PLANAR_V) * data->GetHeight(PLANAR_V); + uint32_t pitch_data_size = pitch_data_sizeY + pitch_data_sizeU + pitch_data_sizeV; + + if (msg.sz != (pitch_data_size + sizeof(FRAME_DATA))) + { + DEBUG_PRINTF_RED("avsfilter : PUT_FRAME_WITH_PITCH error : msg.sz [%d] != pitch_data_size + sizeof(FRAME_DATA) [%d,%d]\n", + msg.sz, pitch_data_size, sizeof(FRAME_DATA)); return 0; } - DEBUG_PRINTF("avsfilter : read %d frame number U plane\n", fd.frame); - if (!receive_bit_blt(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, - data->GetWritePtr(PLANAR_U), data->GetPitch(PLANAR_U), - data->GetWidth(PLANAR_U), data->GetHeight(PLANAR_U))) - { - DEBUG_PRINTF_RED("avsfilter : receive data error#3\n"); + if (ppread(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, (void*)data->GetReadPtr(PLANAR_Y), pitch_data_sizeY) != pitch_data_sizeY || + ppread(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, (void*)data->GetReadPtr(PLANAR_U), pitch_data_sizeU) != pitch_data_sizeU || + ppread(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, (void*)data->GetReadPtr(PLANAR_V), pitch_data_sizeV) != pitch_data_sizeV) + { + DEBUG_PRINTF_RED("avsfilter : receive data error for PUT_FRAME_WITH_PITCH\n"); return 0; + } } - DEBUG_PRINTF("avsfilter : read %d frame number V plane\n", fd.frame); - if (!receive_bit_blt(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, - data->GetWritePtr(PLANAR_V), data->GetPitch(PLANAR_V), - data->GetWidth(PLANAR_V), data->GetHeight(PLANAR_V))) + else { + // DEBUG_PRINTF("avsfilter : read %d frame number Y plane\n", fd.frame); + if (!receive_bit_blt(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, + data->GetWritePtr(PLANAR_Y), data->GetPitch(PLANAR_Y), + data->GetWidth(PLANAR_Y), data->GetHeight(PLANAR_Y))) + { + DEBUG_PRINTF_RED("avsfilter : receive data error#2\n"); + return 0; + } + +// DEBUG_PRINTF("avsfilter : read %d frame number U plane\n", fd.frame); + if (!receive_bit_blt(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, + data->GetWritePtr(PLANAR_U), data->GetPitch(PLANAR_U), + data->GetWidth(PLANAR_U), data->GetHeight(PLANAR_U))) + { + DEBUG_PRINTF_RED("avsfilter : receive data error#3\n"); + return 0; + } +// DEBUG_PRINTF("avsfilter : read %d frame number V plane\n", fd.frame); + if (!receive_bit_blt(wine_loader->avs_pipes[PIPE_LOADER_READ].hpipe, + data->GetWritePtr(PLANAR_V), data->GetPitch(PLANAR_V), + data->GetWidth(PLANAR_V), data->GetHeight(PLANAR_V))) + { DEBUG_PRINTF_RED("avsfilter : receive data error#4\n"); return 0; + } } // *len = out_frame_sz; DEBUG_PRINTF("avsfilter : copy data\n"); DEBUG_PRINTF("avsfilter : data parameters %d:%d\n", - data->_width, data->_height); + data->_width, data->_height); data->copyInfo(_uncompressed); data->Pts = _uncompressed->Pts; // vidCache->unlockAll(); diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/avsfilter/avsfilter.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/avsfilter/avsfilter.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/avsfilter/avsfilter.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/avsfilter/avsfilter.h 2014-03-12 06:15:23.000000000 +0000 @@ -60,6 +60,7 @@ protected: ADM_coreVideoFilter *in; ADMImage *_uncompressed; + PITCH_DATA pd_pipe_source, pd_avsloader; unsigned char *tmp_buf; char *prefs_name; // pointer to filename with preferences // VideoCache *vidCache; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/avsfilter/avspipecomm.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/avsfilter/avspipecomm.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6/avsfilter/avspipecomm.h 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6/avsfilter/avspipecomm.h 2014-03-12 06:15:23.000000000 +0000 @@ -26,7 +26,12 @@ GET_FRAME, PUT_FRAME, //4 UNLOAD_AVS_SCRIPT, - UNLOAD_AVS_LOADER + UNLOAD_AVS_LOADER, + SEND_PITCH_DATA_PIPE_SOURCE, + SEND_PITCH_DATA_AVSLOADER, + GET_PITCH_DATA, + GET_FRAME_WITH_PITCH, + PUT_FRAME_WITH_PITCH } AVS_CMD; typedef struct @@ -58,6 +63,13 @@ unsigned char frame_data[0]; } FRAME_DATA; +typedef struct +{ + uint32_t pitchY; + uint32_t pitchU; + uint32_t pitchV; +}PITCH_DATA; + bool send_cmd(int hw, AVS_CMD cmd, void *data, int sz); @@ -79,3 +91,4 @@ int ppwrite(int h, void *data, int sz); #define PIPE_MAX_TRANSFER_SZ 65536/2 +#define MAGIC_ADV_PROTOCOL_VAL 0xADBACEED diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/CMakeLists.txt avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/CMakeLists.txt --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/CMakeLists.txt 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,26 @@ +INCLUDE(vf_plugin) +INCLUDE(vf_plugin_qt4gl) + + +SET(LibGliphy_SRCS +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-arc.cc +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-arcs.cc +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-blob.cc +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-extents.cc +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-outline.cc +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-sdf.cc +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-shaders.cc +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-arc-bezier.hh +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-arcs-bezier.hh +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-common.hh +${CMAKE_CURRENT_SOURCE_DIR}/glyphy/glyphy-geometry.hh +) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/glyphy) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) + +SET(ADM_vf_GlGlyphy_SRCS glGlyphy.cpp ${LibGliphy_SRCS}) + +ADD_DEFINITIONS(-DPKGDATADIR="") + +INIT_VIDEO_FILTER_GLQT4(ADM_vf_GlGlyphy "${ADM_vf_GlGlyphy_SRCS}" "" "glGlyphy" ) + diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.cpp avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.cpp --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.cpp 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.cpp 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,265 @@ +/** ************************************************************************* + \fn openGlFragmentSample.cpp + \brief simple fragment shader + + That one is performing the same shader 3 times, one time per plane. + + + copyright : (C) 2011 by mean + +bench : 1280*720, null shader, 20 ms, 95% of it in download texture. + Download Texture + RGB2Y=5ms (MMX it) + toQimage=14 ms <<== TOO SLOW + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "ADM_openGL.h" +#define ADM_LEGACY_PROGGY +#include "ADM_default.h" +#include "ADM_coreVideoFilterInternal.h" +#include "T_openGL.h" +#include "T_openGLFilter.h" +#include "glGlyphy.h" +#include "ADM_clock.h" +/** + +*/ + +//#define BENCH 1 +//#define BENCH_READTEXTURE + + +/** + \class openGlSample +*/ +class openGlSample : public ADM_coreVideoFilterQtGl +{ +protected: +protected: + //bool uploadTexture(ADMImage *image, ADM_PLANE plane); + bool render(ADMImage *image,ADM_PLANE plane,QGLFramebufferObject *fbo); + void tinyUploadTex(ADMImage *img, ADM_PLANE plane, GLuint tex,int texNum ); +public: + openGlSample(ADM_coreVideoFilter *previous,CONFcouple *conf); + ~openGlSample(); + + virtual const char *getConfiguration(void); /// Return current configuration as a human readable string + virtual bool getNextFrame(uint32_t *fn,ADMImage *image); /// Return the next image + // virtual FilterInfo *getInfo(void); /// Return picture parameters after this filter + virtual bool getCoupledConf(CONFcouple **couples) ; /// Return the current filter configuration + virtual void setCoupledConf(CONFcouple *couples); + virtual bool configure(void) {return true;} /// Start graphical user interface +}; + +// Add the hook to make it valid plugin +DECLARE_VIDEO_FILTER( openGlSample, // Class + 1,0,0, // Version + ADM_UI_QT4+ADM_FEATURE_OPENGL, // UI + VF_OPENGL, // Category + "glsampleFragment", // internal name (must be uniq!) + "OpenGl Fragment Shader Sample", // Display name + "Run a fragment shader." // Description + ); + +// Now implements the interesting parts +/** + \fn openGlSample + \brief constructor +*/ +openGlSample::openGlSample( ADM_coreVideoFilter *in,CONFcouple *setup) : ADM_coreVideoFilterQtGl(in,setup) +{ +UNUSED_ARG(setup); + widget->makeCurrent(); + fboY->bind(); + printf("Compiling shader \n"); + glProgramY = new QGLShaderProgram(context); + ADM_assert(glProgramY); + if ( !glProgramY->addShaderFromSourceCode(QGLShader::Fragment, myShaderY)) + { + ADM_error("[GL Render] Fragment log: %s\n", glProgramY->log().toUtf8().constData()); + ADM_assert(0); + } + if ( !glProgramY->link()) + { + ADM_error("[GL Render] Link log: %s\n", glProgramY->log().toUtf8().constData()); + ADM_assert(0); + } + + if ( !glProgramY->bind()) + { + ADM_error("[GL Render] Binding FAILED\n"); + ADM_assert(0); + } + fboY->release(); +// + fboUV->bind(); + printf("Compiling shader \n"); + glProgramUV = new QGLShaderProgram(context); + ADM_assert(glProgramUV); + if ( !glProgramUV->addShaderFromSourceCode(QGLShader::Fragment, myShaderY)) + { + ADM_error("[GL Render] Fragment log: %s\n", glProgramUV->log().toUtf8().constData()); + ADM_assert(0); + } + if ( !glProgramUV->link()) + { + ADM_error("[GL Render] Link log: %s\n", glProgramUV->log().toUtf8().constData()); + ADM_assert(0); + } + + if ( !glProgramUV->bind()) + { + ADM_error("[GL Render] Binding FAILED\n"); + ADM_assert(0); + } + fboUV->release(); + widget->doneCurrent(); + +} +/** + \fn openGlSample + \brief destructor +*/ +openGlSample::~openGlSample() +{ + +} + +/** + \fn getFrame + \brief Get a processed frame +*/ +bool openGlSample::getNextFrame(uint32_t *fn,ADMImage *image) +{ + // since we do nothing, just get the output of previous filter + if(false==previousFilter->getNextFrame(fn,image)) + { + ADM_warning("FlipFilter : Cannot get frame\n"); + return false; + } + widget->makeCurrent(); + glPushMatrix(); + float angle=*fn; + angle=angle/40; + + glProgramUV->setUniformValue("kernelSize", 1); // Do a convolution kernelSize*2+1 pixels + glProgramUV->setUniformValue("normalization", 4); + // size is the last one... + fboY->bind(); + // upload kernel... + + // here we go + tinyUploadTex(image,PLANAR_Y,GL_TEXTURE0,0); + render(image,PLANAR_Y,fboY); + downloadTexture(image,PLANAR_Y,fboY); + fboY->release(); + + fboUV->bind(); + tinyUploadTex(image,PLANAR_U,GL_TEXTURE1,1); + glProgramUV->setUniformValue("myTexture", 1); + render(image,PLANAR_U,fboUV); + downloadTexture(image,PLANAR_U,fboUV); + + tinyUploadTex(image,PLANAR_V,GL_TEXTURE2,2); + glProgramUV->setUniformValue("myTexture", 2); + render(image,PLANAR_V,fboUV); + downloadTexture(image,PLANAR_V,fboUV); + fboUV->release(); + firstRun=false; + glPopMatrix(); + widget->doneCurrent(); + + return true; +} +/** + \fn getCoupledConf + \brief Return our current configuration as couple name=value +*/ +bool openGlSample::getCoupledConf(CONFcouple **couples) +{ + *couples=new CONFcouple(0); // Even if we dont have configuration we must allocate one + return true; +} + +void openGlSample::setCoupledConf(CONFcouple *couples) +{ +} +/** + \fn getConfiguration + \brief Return current setting as a string +*/ +const char *openGlSample::getConfiguration(void) +{ + + return "openGl Sample."; +} +/** + \fn uploadTexture +*/ +void openGlSample::tinyUploadTex(ADMImage *image, ADM_PLANE plane, GLuint tex,int texNum ) +{ + // FIXME myGlActiveTexture(tex); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, texNum); + glProgramY->setUniformValue("myTexture", texNum); + glProgramY->setUniformValue("myWidth", image->GetWidth(plane)); + glProgramY->setUniformValue("myHeight", image->GetHeight(plane)); + + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + if(!firstRun) + { + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_LUMINANCE, + image->GetPitch(plane), + image->GetHeight(plane), 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, + image->GetReadPtr(plane)); + }else + { + glTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, + image->GetPitch(plane), + image->GetHeight(plane), + GL_LUMINANCE, GL_UNSIGNED_BYTE, + image->GetReadPtr(plane)); + } +} + + +/** + \fn render +*/ +bool openGlSample::render(ADMImage *image,ADM_PLANE plane,QGLFramebufferObject *fbo) +{ + int width=image->GetWidth(plane); + int height=image->GetHeight(plane); + + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, width, 0, height, -1, 1); + + // + glBegin(GL_QUADS); + glTexCoord2i(0, 0); + glVertex2i(0, 0); + glTexCoord2i(width, 0); + glVertex2i(width, 0); + glTexCoord2i(width, height); + glVertex2i(width ,height); + glTexCoord2i(0, height); + glVertex2i(0, height); + glEnd(); // draw cube background + return true; +} +//EOF diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.h 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.h 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,29 @@ +// Invert x & y +static const char *myShaderY = + "#extension GL_ARB_texture_rectangle: enable\n" + "uniform sampler2DRect myTexture;\n" + "uniform int kernelSize;\n" + "uniform int normalization;\n" + + "void main(void) {\n" + " int nx = (int)gl_TexCoord[0].x;\n" + " int ny = (int)gl_TexCoord[0].y;\n" + " float t = 0;\n" + " float mul;\n" + " int x,y;\n" + " for(y=-kernelSize;y<=kernelSize;y++)\n" + " {\n" + " for(x=-kernelSize;x<=kernelSize;x++)\n" + " {\n" + " if(0==x && 0==y){ mul=4;}\n" + " else if(0==x) {mul=-1;}\n" + " else if(0==y) {mul=-1;}\n" + " else {mul=0;}\n" + " t += mul*texture2DRect(myTexture, vec2(nx+x, ny+y)).r;\n" + " }\n" + " }\n" + " t=t/normalization;\n" + " t=t+texture2DRect(myTexture, vec2(nx, ny)).r;\n" + " gl_FragColor = vec4(t, t, t, 1.0);\n" + "}\n"; + diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.ui avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.ui --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.ui 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glGlyphy.ui 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,724 @@ + + resizeDialog + + + + 0 + 0 + 350 + 342 + + + + Resize + + + + 9 + + + 6 + + + + + Aspect Ratio + + + + 9 + + + 6 + + + + + Lock Aspect Ratio + + + true + + + + + + + 0 + + + 6 + + + + + Source: + + + + + + + + 1:1 + + + + + 4:3 + + + + + 16:9 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + Destination: + + + + + + + + 1:1 + + + + + 4:3 + + + + + 16:9 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Resize Dimensions + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + Width: + + + + + + + 2900 + + + 16 + + + 2 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + Height: + + + + + + + 2000 + + + 16 + + + 2 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Round to the Nearest Multiple of 16 + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 312 + 4 + + + + + + + + 0 + + + 6 + + + + + 0 + + + 12 + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + 1% + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Percent + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 200% + + + + + + + + + 1 + + + 200 + + + 100 + + + Qt::Horizontal + + + + + + + + + 200 + + + 1 + + + 100 + + + + + + + + + 0 + + + 6 + + + + + Error X / Y: + + + + + + + 0.00 / 0.00 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 332 + 6 + + + + + + + + 0 + + + 6 + + + + + Resize Method: + + + + + + + + Bilinear + + + + + Bicubic + + + + + Lanzcos3 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 16 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + lockArCheckBox + comboBoxSource + comboBoxDestination + spinBoxWidth + spinBoxHeight + checkBoxRoundup + horizontalSlider + percentageSpinBox + comboBoxAlgo + buttonBox + + + + + buttonBox + rejected() + resizeDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + lockArCheckBox + toggled(bool) + label_8 + setEnabled(bool) + + + 184 + 117 + + + 39 + 148 + + + + + lockArCheckBox + toggled(bool) + label_5 + setEnabled(bool) + + + 184 + 117 + + + 150 + 148 + + + + + lockArCheckBox + toggled(bool) + label_9 + setEnabled(bool) + + + 184 + 117 + + + 267 + 148 + + + + + lockArCheckBox + toggled(bool) + horizontalSlider + setEnabled(bool) + + + 184 + 117 + + + 156 + 164 + + + + + lockArCheckBox + toggled(bool) + percentageSpinBox + setEnabled(bool) + + + 184 + 117 + + + 317 + 155 + + + + + lockArCheckBox + toggled(bool) + checkBoxRoundup + setEnabled(bool) + + + 184 + 95 + + + 184 + 117 + + + + + lockArCheckBox + toggled(bool) + label_10 + setEnabled(bool) + + + 182 + 155 + + + 55 + 251 + + + + + lockArCheckBox + toggled(bool) + labelErrorXY + setEnabled(bool) + + + 182 + 155 + + + 114 + 251 + + + + + lockArCheckBox + toggled(bool) + label_4 + setEnabled(bool) + + + 182 + 69 + + + 46 + 95 + + + + + lockArCheckBox + toggled(bool) + comboBoxSource + setEnabled(bool) + + + 182 + 69 + + + 94 + 95 + + + + + lockArCheckBox + toggled(bool) + label_3 + setEnabled(bool) + + + 182 + 69 + + + 188 + 95 + + + + + lockArCheckBox + toggled(bool) + comboBoxDestination + setEnabled(bool) + + + 182 + 69 + + + 247 + 95 + + + + + diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arc-bezier.hh avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arc-bezier.hh --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arc-bezier.hh 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arc-bezier.hh 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,228 @@ +/* + * Copyright 2012,2013 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju + */ + +#ifndef GLYPHY_ARC_BEZIER_HH +#define GLYPHY_ARC_BEZIER_HH + +#include "glyphy-common.hh" +#include "glyphy-geometry.hh" + +namespace GLyphy { +namespace ArcBezier { + +using namespace Geometry; + + +class MaxDeviationApproximatorExact +{ + public: + /* Returns 3 max(abs(d₀ t (1-t)² + d₁ t² (1-t)) for 0≤t≤1. */ + static double approximate_deviation (double d0, double d1) + { + double candidates[4] = {0,1}; + unsigned int num_candidates = 2; + if (d0 == d1) + candidates[num_candidates++] = .5; + else { + double delta = d0*d0 - d0*d1 + d1*d1; + double t2 = 1. / (3 * (d0 - d1)); + double t0 = (2 * d0 - d1) * t2; + if (delta == 0) + candidates[num_candidates++] = t0; + else if (delta > 0) { + /* This code can be optimized to avoid the sqrt if the solution + * is not feasible (ie. lies outside (0,1)). I have implemented + * that in cairo-spline.c:_cairo_spline_bound(). Can be reused + * here. + */ + double t1 = sqrt (delta) * t2; + candidates[num_candidates++] = t0 - t1; + candidates[num_candidates++] = t0 + t1; + } + } + + double e = 0; + for (unsigned int i = 0; i < num_candidates; i++) { + double t = candidates[i]; + double ee; + if (t < 0. || t > 1.) + continue; + ee = fabs (3 * t * (1-t) * (d0 * (1 - t) + d1 * t)); + e = std::max (e, ee); + } + + return e; + } +}; + + + +template +class ArcBezierErrorApproximatorBehdad +{ + public: + static double approximate_bezier_arc_error (const Bezier &b0, const Arc &a) + { + assert (b0.p0 == a.p0); + assert (b0.p3 == a.p1); + + double ea; + Bezier b1 = a.approximate_bezier (&ea); + + assert (b0.p0 == b1.p0); + assert (b0.p3 == b1.p3); + + Vector v0 = b1.p1 - b0.p1; + Vector v1 = b1.p2 - b0.p2; + + Vector b = (b0.p3 - b0.p0).normalized (); + v0 = v0.rebase (b); + v1 = v1.rebase (b); + + Vector v (MaxDeviationApproximator::approximate_deviation (v0.dx, v1.dx), + MaxDeviationApproximator::approximate_deviation (v0.dy, v1.dy)); + + /* Edge cases: If d*d is too close too large default to a weak bound. */ + if (a.d * a.d > 1. - 1e-4) + return ea + v.len (); + + /* If the wedge doesn't contain control points, default to weak bound. */ + if (!a.wedge_contains_point (b0.p1) || !a.wedge_contains_point (b0.p2)) + return ea + v.len (); + + /* If straight line, return the max ortho deviation. */ + if (fabs (a.d) < 1e-6) + return ea + v.dy; + + /* We made sure that fabs(a.d) < 1 */ + double tan_half_alpha = fabs (tan2atan (a.d)); + + double tan_v = v.dx / v.dy; + + double eb; + if (fabs (tan_v) <= tan_half_alpha) + return ea + v.len (); + + double c2 = (a.p1 - a.p0).len () * .5; + double r = a.radius (); + + eb = Vector (c2 + v.dx, c2 / tan_half_alpha + v.dy).len () - r; + assert (eb >= 0); + + return ea + eb; + } +}; + + + +template +class ArcBezierApproximatorMidpointSimple +{ + public: + static const Arc approximate_bezier_with_arc (const Bezier &b, double *error) + { + Arc a (b.p0, b.p3, b.midpoint (), false); + + *error = ArcBezierErrorApproximator::approximate_bezier_arc_error (b, a); + + return a; + } +}; + +template +class ArcBezierApproximatorMidpointTwoPart +{ + public: + static const Arc approximate_bezier_with_arc (const Bezier &b, double *error, double mid_t = .5) + { + Pair pair = b.split (mid_t); + Point m = pair.second.p0; + + Arc a0 (b.p0, m, b.p3, true); + Arc a1 (m, b.p3, b.p0, true); + + double e0 = ArcBezierErrorApproximator::approximate_bezier_arc_error (pair.first, a0); + double e1 = ArcBezierErrorApproximator::approximate_bezier_arc_error (pair.second, a1); + *error = std::max (e0, e1); + + return Arc (b.p0, b.p3, m, false); + } +}; + +template +class ArcBezierApproximatorQuantized +{ + public: + ArcBezierApproximatorQuantized (double _max_d = GLYPHY_INFINITY, unsigned int _d_bits = 0) : + max_d (_max_d), d_bits (_d_bits) {}; + + protected: + double max_d; + unsigned int d_bits; + + public: + const Arc approximate_bezier_with_arc (const Bezier &b, double *error) const + { + double mid_t = .5; + Arc a (b.p0, b.p3, b.point (mid_t), false); + Arc orig_a = a; + + if (isfinite (max_d)) { + assert (max_d >= 0); + if (fabs (a.d) > max_d) + a.d = a.d < 0 ? -max_d : max_d; + } + if (d_bits && max_d != 0) { + assert (isfinite (max_d)); + assert (fabs (a.d) <= max_d); + int mult = (1 << (d_bits - 1)) - 1; + int id = round (a.d / max_d * mult); + assert (-mult <= id && id <= mult); + a.d = id * max_d / mult; + assert (fabs (a.d) <= max_d); + } + + /* Error introduced by arc quantization */ + double ed = fabs (a.d - orig_a.d) * (a.p1 - a.p0).len () * .5; + + ArcBezierApproximatorMidpointTwoPart + ::approximate_bezier_with_arc (b, error, mid_t); + + if (ed) { + *error += ed; + + /* Try a simple one-arc approx which works with the quantized arc. + * May produce smaller error bound. */ + double e = ArcBezierErrorApproximator::approximate_bezier_arc_error (b, a); + if (e < *error) + *error = e; + } + + return a; + } +}; + +typedef MaxDeviationApproximatorExact MaxDeviationApproximatorDefault; +typedef ArcBezierErrorApproximatorBehdad ArcBezierErrorApproximatorDefault; +typedef ArcBezierApproximatorMidpointTwoPart ArcBezierApproximatorDefault; +typedef ArcBezierApproximatorQuantized ArcBezierApproximatorQuantizedDefault; + +} /* namespace ArcBezier */ +} /* namespace GLyphy */ + +#endif /* GLYPHY_ARC_BEZIER_HH */ diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arc.cc avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arc.cc --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arc.cc 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arc.cc 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,137 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju, Wojciech Baranowski + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "glyphy-common.hh" +#include "glyphy-geometry.hh" +#include "glyphy-arc-bezier.hh" + +using namespace GLyphy::Geometry; +using namespace GLyphy::ArcBezier; + + + +/* + * Circular arcs + */ + + +/* Build from a conventional arc representation */ +void +glyphy_arc_from_conventional (const glyphy_point_t *center, + double radius, + double angle0, + double angle1, + glyphy_bool_t negative, + glyphy_arc_t *arc) +{ + *arc = Arc (*center, radius, angle0, angle1, negative); +}; + +/* Convert to a conventional arc representation */ +void +glyphy_arc_to_conventional (glyphy_arc_t arc, + glyphy_point_t *center /* may be NULL */, + double *radius /* may be NULL */, + double *angle0 /* may be NULL */, + double *angle1 /* may be NULL */, + glyphy_bool_t *negative /* may be NULL */) +{ + Arc a (arc); + if (radius) *radius = a.radius (); + if (center || angle0 || angle1) { + Point c = a.center (); + if (center) *center = c; + if (angle0) *angle0 = (a.p0 - c).angle (); + if (angle1) *angle1 = (a.p1 - c).angle (); + if (negative) *negative = a.d < 0; + } +} + +glyphy_bool_t +glyphy_arc_is_a_line (glyphy_arc_t arc) +{ + return arc.d == 0; +} + +void +glyphy_arc_extents (glyphy_arc_t arc, + glyphy_extents_t *extents) +{ + Arc(arc).extents (*extents); +} + + +/* + * Approximate single pieces of geometry to/from one arc + */ + + +void +glyphy_arc_from_line (const glyphy_point_t *p0, + const glyphy_point_t *p1, + glyphy_arc_t *arc) +{ + *arc = Arc (*p0, *p1, 0); +} + +void +glyphy_arc_from_conic (const glyphy_point_t *p0, + const glyphy_point_t *p1, + const glyphy_point_t *p2, + glyphy_arc_t *arc, + double *error) +{ + Point p1_ (Point (*p0).lerp (2/3., *p1)); + Point p2_ (Point (*p2).lerp (2/3., *p1)); + glyphy_arc_from_cubic (p0, + &p1_, + &p2_, + p2, + arc, + error); +} + +void +glyphy_arc_from_cubic (const glyphy_point_t *p0, + const glyphy_point_t *p1, + const glyphy_point_t *p2, + const glyphy_point_t *p3, + glyphy_arc_t *arc, + double *error) +{ + *arc = ArcBezierApproximatorDefault::approximate_bezier_with_arc (Bezier (*p0, *p1, *p2, *p3), error); +} + +void +glyphy_arc_to_cubic (const glyphy_arc_t *arc, + glyphy_point_t *p0, + glyphy_point_t *p1, + glyphy_point_t *p2, + glyphy_point_t *p3, + double *error) +{ + Bezier b = Arc (*arc).approximate_bezier (error); + *p0 = arc->p0; + *p1 = b.p1; + *p2 = b.p2; + *p3 = arc->p1; +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arcs-bezier.hh avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arcs-bezier.hh --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arcs-bezier.hh 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arcs-bezier.hh 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,138 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju + */ + +#ifndef GLYPHY_ARCS_BEZIER_HH +#define GLYPHY_ARCS_BEZIER_HH + +#include "glyphy-common.hh" +#include "glyphy-geometry.hh" +#include "glyphy-arc-bezier.hh" + +namespace GLyphy { +namespace ArcsBezier { + +using namespace Geometry; +using namespace ArcBezier; + +template +class ArcsBezierApproximatorSpringSystem +{ + static inline void calc_arcs (const Bezier &b, + const std::vector &t, + const ArcBezierApproximator &appx, + std::vector &e, + std::vector &arcs, + double &max_e, double &min_e) + { + unsigned int n = t.size () - 1; + e.resize (n); + arcs.clear (); + max_e = 0; + min_e = GLYPHY_INFINITY; + for (unsigned int i = 0; i < n; i++) + { + Bezier segment = b.segment (t[i], t[i + 1]); + arcs.push_back (appx.approximate_bezier_with_arc (segment, &e[i])); + + max_e = std::max (max_e, e[i]); + min_e = std::min (min_e, e[i]); + } + } + + static inline void jiggle (const Bezier &b, + const ArcBezierApproximator &appx, + std::vector &t, + std::vector &e, + std::vector &arcs, + double &max_e, double &min_e, + double tolerance, + unsigned int &n_jiggle) + { + unsigned int n = t.size () - 1; + //fprintf (stderr, "candidate n %d max_e %g min_e %g\n", n, max_e, min_e); + unsigned int max_jiggle = log2 (n) + 1; + unsigned int s; + for (s = 0; s < max_jiggle; s++) + { + double total = 0; + for (unsigned int i = 0; i < n; i++) { + double l = t[i + 1] - t[i]; + double k_inv = l * pow (e[i], -.3); + total += k_inv; + e[i] = k_inv; + } + for (unsigned int i = 0; i < n; i++) { + double k_inv = e[i]; + double l = k_inv / total; + t[i + 1] = t[i] + l; + } + t[n] = 1.0; // Do this to get real 1.0, not .9999999999999998! + + calc_arcs (b, t, appx, e, arcs, max_e, min_e); + + //fprintf (stderr, "n %d jiggle %d max_e %g min_e %g\n", n, s, max_e, min_e); + + n_jiggle++; + if (max_e < tolerance || (2 * min_e - max_e > tolerance)) + break; + } + //if (s == max_jiggle) fprintf (stderr, "JIGGLE OVERFLOW n %d s %d\n", n, s); + } + + public: + static void approximate_bezier_with_arcs (const Bezier &b, + double tolerance, + const ArcBezierApproximator &appx, + std::vector &arcs, + double *perror, + unsigned int max_segments = 100) + { + std::vector t; + std::vector e; + double max_e, min_e; + unsigned int n_jiggle = 0; + + /* Technically speaking we can bsearch for n. */ + for (unsigned int n = 1; n <= max_segments; n++) + { + t.resize (n + 1); + for (unsigned int i = 0; i < n; i++) + t[i] = double (i) / n; + t[n] = 1.0; // Do this out of the loop to get real 1.0, not .9999999999999998! + + calc_arcs (b, t, appx, e, arcs, max_e, min_e); + + for (unsigned int i = 0; i < n; i++) + if (e[i] <= tolerance) { + jiggle (b, appx, t, e, arcs, max_e, min_e, tolerance, n_jiggle); + break; + } + + if (max_e <= tolerance) + break; + } + if (perror) + *perror = max_e; + //fprintf (stderr, "n_jiggle %d\n", n_jiggle); + } +}; + +} /* namespace ArcsBezier */ +} /* namespace GLyphy */ + +#endif /* GLYPHY_ARCS_BEZIER_HH */ diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arcs.cc avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arcs.cc --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arcs.cc 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-arcs.cc 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,320 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju, Wojciech Baranowski + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "glyphy-common.hh" +#include "glyphy-geometry.hh" +#include "glyphy-arcs-bezier.hh" + +using namespace GLyphy::Geometry; +using namespace GLyphy::ArcsBezier; + + + +/* + * Approximate outlines with multiple arcs + */ + + +struct glyphy_arc_accumulator_t { + unsigned int refcount; + + double tolerance; + double max_d; + unsigned int d_bits; + glyphy_arc_endpoint_accumulator_callback_t callback; + void *user_data; + + glyphy_point_t start_point; + glyphy_point_t current_point; + bool need_moveto; + unsigned int num_endpoints; + double max_error; + glyphy_bool_t success; +}; + + +glyphy_arc_accumulator_t * +glyphy_arc_accumulator_create (void) +{ + glyphy_arc_accumulator_t *acc = (glyphy_arc_accumulator_t *) calloc (1, sizeof (glyphy_arc_accumulator_t)); + acc->refcount = 1; + + acc->tolerance = 5e-4; + acc->max_d = GLYPHY_MAX_D; + acc->d_bits = 8; + acc->callback = NULL; + acc->user_data = NULL; + + glyphy_arc_accumulator_reset (acc); + + return acc; +} + +void +glyphy_arc_accumulator_reset (glyphy_arc_accumulator_t *acc) +{ + acc->start_point = acc->current_point = Point (0, 0); + acc->need_moveto = true; + acc->num_endpoints = 0; + acc->max_error = 0; + acc->success = true; +} + +void +glyphy_arc_accumulator_destroy (glyphy_arc_accumulator_t *acc) +{ + if (!acc || --acc->refcount) + return; + + free (acc); +} + +glyphy_arc_accumulator_t * +glyphy_arc_accumulator_reference (glyphy_arc_accumulator_t *acc) +{ + if (acc) + acc->refcount++; + return acc; +} + + +/* Configure acc */ + +void +glyphy_arc_accumulator_set_tolerance (glyphy_arc_accumulator_t *acc, + double tolerance) +{ + acc->tolerance = tolerance; +} + +double +glyphy_arc_accumulator_get_tolerance (glyphy_arc_accumulator_t *acc) +{ + return acc->tolerance; +} + +void +glyphy_arc_accumulator_set_callback (glyphy_arc_accumulator_t *acc, + glyphy_arc_endpoint_accumulator_callback_t callback, + void *user_data) +{ + acc->callback = callback; + acc->user_data = user_data; +} + +void +glyphy_arc_accumulator_get_callback (glyphy_arc_accumulator_t *acc, + glyphy_arc_endpoint_accumulator_callback_t *callback, + void **user_data) +{ + *callback = acc->callback; + *user_data = acc->user_data; +} + +void +glyphy_arc_accumulator_set_d_metrics (glyphy_arc_accumulator_t *acc, + double max_d, + double d_bits) +{ + acc->max_d = max_d; + acc->d_bits = d_bits; +} + +void +glyphy_arc_accumulator_get_d_metrics (glyphy_arc_accumulator_t *acc, + double *max_d, + double *d_bits) +{ + *max_d = acc->max_d; + *d_bits = acc->d_bits; +} + + +/* Accumulation results */ + +unsigned int +glyphy_arc_accumulator_get_num_endpoints (glyphy_arc_accumulator_t *acc) +{ + return acc->num_endpoints; +} + +double +glyphy_arc_accumulator_get_error (glyphy_arc_accumulator_t *acc) +{ + return acc->max_error; +} + +glyphy_bool_t +glyphy_arc_accumulator_successful (glyphy_arc_accumulator_t *acc) +{ + return acc->success; +} + + +/* Accumulate */ + +static void +emit (glyphy_arc_accumulator_t *acc, const Point &p, double d) +{ + glyphy_arc_endpoint_t endpoint = {p, d}; + acc->success = acc->success && acc->callback (&endpoint, acc->user_data); + if (acc->success) { + acc->num_endpoints++; + acc->current_point = p; + } +} + +static void +accumulate (glyphy_arc_accumulator_t *acc, const Point &p, double d) +{ + if (Point (acc->current_point) == p) + return; + if (d == GLYPHY_INFINITY) { + /* Emit moveto lazily, for cleaner outlines */ + acc->need_moveto = true; + acc->current_point = p; + return; + } + if (acc->need_moveto) { + emit (acc, acc->current_point, GLYPHY_INFINITY); + if (acc->success) { + acc->start_point = acc->current_point; + acc->need_moveto = false; + } + } + emit (acc, p, d); +} + +static void +move_to (glyphy_arc_accumulator_t *acc, const Point &p) +{ + if (!acc->num_endpoints || p != acc->current_point) + accumulate (acc, p, GLYPHY_INFINITY); +} + +static void +arc_to (glyphy_arc_accumulator_t *acc, const Point &p1, double d) +{ + accumulate (acc, p1, d); +} + +static void +bezier (glyphy_arc_accumulator_t *acc, const Bezier &b) +{ + double e; + + std::vector arcs; + typedef ArcBezierApproximatorQuantizedDefault _ArcBezierApproximator; + _ArcBezierApproximator appx (acc->max_d, acc->d_bits); + ArcsBezierApproximatorSpringSystem<_ArcBezierApproximator> + ::approximate_bezier_with_arcs (b, acc->tolerance, appx, arcs, &e); + + acc->max_error = std::max (acc->max_error, e); + + move_to (acc, b.p0); + for (unsigned int i = 0; i < arcs.size (); i++) + arc_to (acc, arcs[i].p1, arcs[i].d); +} + +static void +close_path (glyphy_arc_accumulator_t *acc) +{ + if (!acc->need_moveto && Point (acc->current_point) != Point (acc->start_point)) + arc_to (acc, acc->start_point, 0); +} + +void +glyphy_arc_accumulator_move_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p0) +{ + move_to (acc, *p0); +} + +void +glyphy_arc_accumulator_line_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p1) +{ + arc_to (acc, *p1, 0); +} + +void +glyphy_arc_accumulator_conic_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p1, + const glyphy_point_t *p2) +{ + bezier (acc, Bezier (acc->current_point, + Point (acc->current_point).lerp (2/3., *p1), + Point (*p2).lerp (2/3., *p1), + *p2)); +} + +void +glyphy_arc_accumulator_cubic_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p1, + const glyphy_point_t *p2, + const glyphy_point_t *p3) +{ + bezier (acc, Bezier (acc->current_point, *p1, *p2, *p3)); +} + +void +glyphy_arc_accumulator_arc_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p1, + double d) +{ + arc_to (acc, *p1, d); +} + +void +glyphy_arc_accumulator_close_path (glyphy_arc_accumulator_t *acc) +{ + close_path (acc); +} + + + +/* + * Outline extents from arc list + */ + + +void +glyphy_arc_list_extents (const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + glyphy_extents_t *extents) +{ + Point p0 (0, 0); + glyphy_extents_clear (extents); + for (unsigned int i = 0; i < num_endpoints; i++) { + const glyphy_arc_endpoint_t &endpoint = endpoints[i]; + if (endpoint.d == GLYPHY_INFINITY) { + p0 = endpoint.p; + continue; + } + Arc arc (p0, endpoint.p, endpoint.d); + p0 = endpoint.p; + + glyphy_extents_t arc_extents; + arc.extents (arc_extents); + glyphy_extents_extend (extents, &arc_extents); + } +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-blob.cc avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-blob.cc --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-blob.cc 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-blob.cc 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,322 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju, Wojciech Baranowski + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "glyphy-common.hh" +#include "glyphy-geometry.hh" + +#define GRID_SIZE 24 + +using namespace GLyphy::Geometry; + + +#define UPPER_BITS(v,bits,total_bits) ((v) >> ((total_bits) - (bits))) +#define LOWER_BITS(v,bits,total_bits) ((v) & ((1 << (bits)) - 1)) + +#define MAX_X 4095 +#define MAX_Y 4095 + +static inline glyphy_rgba_t +arc_endpoint_encode (unsigned int ix, unsigned int iy, double d) +{ + glyphy_rgba_t v; + + /* 12 bits for each of x and y, 8 bits for d */ + assert (ix <= MAX_X); + assert (iy <= MAX_Y); + unsigned int id; + if (isinf (d)) + id = 0; + else { + assert (fabs (d) <= GLYPHY_MAX_D); + id = 128 + lround (d * 127 / GLYPHY_MAX_D); + } + assert (id < 256); + + v.r = id; + v.g = LOWER_BITS (ix, 8, 12); + v.b = LOWER_BITS (iy, 8, 12); + v.a = ((ix >> 8) << 4) | (iy >> 8); + return v; +} + +static inline glyphy_rgba_t +arc_list_encode (unsigned int offset, unsigned int num_points, int side) +{ + glyphy_rgba_t v; + v.r = 0; // unused for arc-list encoding + v.g = UPPER_BITS (offset, 8, 16); + v.b = LOWER_BITS (offset, 8, 16); + v.a = LOWER_BITS (num_points, 8, 8); + if (side < 0 && !num_points) + v.a = 255; + return v; +} + +static inline glyphy_rgba_t +line_encode (const Line &line) +{ + Line l = line.normalized (); + double angle = l.n.angle (); + double distance = l.c; + + int ia = lround (-angle / M_PI * 0x7FFF); + unsigned int ua = ia + 0x8000; + assert (0 == (ua & ~0xFFFF)); + + int id = lround (distance * 0x1FFF); + unsigned int ud = id + 0x4000; + assert (0 == (ud & ~0x7FFF)); + + /* Marker for line-encoded */ + ud |= 0x8000; + + glyphy_rgba_t v; + v.r = ud >> 8; + v.g = ud & 0xFF; + v.b = ua >> 8; + v.a = ua & 0xFF; + return v; +} + + +/* Given a cell, fills the vector closest_arcs with arcs that may be closest to some point in the cell. + * Uses idea that all close arcs to cell must be ~close to center of cell. + */ +static void +closest_arcs_to_cell (Point c0, Point c1, /* corners */ + double faraway, + const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + std::vector &near_endpoints, + int *side) +{ + // Find distance between cell center + Point c = c0.midpoint (c1); + double min_dist = glyphy_sdf_from_arc_list (endpoints, num_endpoints, &c, NULL); + + *side = min_dist >= 0 ? +1 : -1; + min_dist = fabs (min_dist); + std::vector near_arcs; + + // If d is the distance from the center of the square to the nearest arc, then + // all nearest arcs to the square must be at most almost [d + half_diagonal] from the center. + double half_diagonal = (c - c0).len (); + double radius_squared = pow (min_dist + half_diagonal, 2); + if (min_dist - half_diagonal <= faraway) { + Point p0 (0, 0); + for (unsigned int i = 0; i < num_endpoints; i++) { + const glyphy_arc_endpoint_t &endpoint = endpoints[i]; + if (endpoint.d == GLYPHY_INFINITY) { + p0 = endpoint.p; + continue; + } + Arc arc (p0, endpoint.p, endpoint.d); + p0 = endpoint.p; + + if (arc.squared_distance_to_point (c) <= radius_squared) + near_arcs.push_back (arc); + } + } + + Point p1 = Point (0, 0); + for (unsigned i = 0; i < near_arcs.size (); i++) + { + Arc arc = near_arcs[i]; + + if (i == 0 || p1 != arc.p0) { + glyphy_arc_endpoint_t endpoint = {arc.p0, GLYPHY_INFINITY}; + near_endpoints.push_back (endpoint); + p1 = arc.p0; + } + + glyphy_arc_endpoint_t endpoint = {arc.p1, arc.d}; + near_endpoints.push_back (endpoint); + p1 = arc.p1; + } +} + + +glyphy_bool_t +glyphy_arc_list_encode_blob (const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + glyphy_rgba_t *blob, + unsigned int blob_size, + double faraway, + double avg_fetch_desired, + double *avg_fetch_achieved, + unsigned int *output_len, + unsigned int *nominal_width, /* 8bit */ + unsigned int *nominal_height, /* 8bit */ + glyphy_extents_t *pextents) +{ + glyphy_extents_t extents; + glyphy_extents_clear (&extents); + + glyphy_arc_list_extents (endpoints, num_endpoints, &extents); + + if (glyphy_extents_is_empty (&extents)) { + *pextents = extents; + if (!blob_size) + return false; + *blob = arc_list_encode (0, 0, +1); + *avg_fetch_achieved = 1; + *output_len = 1; + *nominal_width = *nominal_height = 1; + return true; + } + + /* Add antialiasing padding */ + extents.min_x -= faraway; + extents.min_y -= faraway; + extents.max_x += faraway; + extents.max_y += faraway; + + double glyph_width = extents.max_x - extents.min_x; + double glyph_height = extents.max_y - extents.min_y; + double unit = std::max (glyph_width, glyph_height); + + unsigned int grid_w = GRID_SIZE; + unsigned int grid_h = GRID_SIZE; + + if (glyph_width > glyph_height) { + while ((grid_h - 1) * unit / grid_w > glyph_height) + grid_h--; + glyph_height = grid_h * unit / grid_w; + extents.max_y = extents.min_y + glyph_height; + } else { + while ((grid_w - 1) * unit / grid_h > glyph_width) + grid_w--; + glyph_width = grid_w * unit / grid_h; + extents.max_x = extents.min_x + glyph_width; + } + + double cell_unit = unit / std::max (grid_w, grid_h); + + std::vector tex_data; + std::vector near_endpoints; + + unsigned int header_length = grid_w * grid_h; + unsigned int offset = header_length; + tex_data.resize (header_length); + Point origin = Point (extents.min_x, extents.min_y); + unsigned int total_arcs = 0; + + for (unsigned int row = 0; row < grid_h; row++) + for (unsigned int col = 0; col < grid_w; col++) + { + Point cp0 = origin + Vector ((col + 0) * cell_unit, (row + 0) * cell_unit); + Point cp1 = origin + Vector ((col + 1) * cell_unit, (row + 1) * cell_unit); + near_endpoints.clear (); + + int side; + closest_arcs_to_cell (cp0, cp1, + faraway, + endpoints, num_endpoints, + near_endpoints, + &side); + +#define QUANTIZE_X(X) (lround (MAX_X * ((X - extents.min_x) / glyph_width ))) +#define QUANTIZE_Y(Y) (lround (MAX_Y * ((Y - extents.min_y) / glyph_height))) +#define DEQUANTIZE_X(X) (double (X) / MAX_X * glyph_width + extents.min_x) +#define DEQUANTIZE_Y(Y) (double (Y) / MAX_Y * glyph_height + extents.min_y) +#define SNAP(P) (Point (DEQUANTIZE_X (QUANTIZE_X ((P).x)), DEQUANTIZE_Y (QUANTIZE_Y ((P).y)))) + + if (near_endpoints.size () == 2 && near_endpoints[1].d == 0) { + Point c (extents.min_x + glyph_width * .5, extents.min_y + glyph_height * .5); + Line line (SNAP (near_endpoints[0].p), SNAP (near_endpoints[1].p)); + line.c -= line.n * Vector (c); + line.c /= unit; + tex_data[row * grid_w + col] = line_encode (line); + continue; + } + + /* If the arclist is two arcs that can be combined in encoding if reordered, + * do that. */ + if (near_endpoints.size () == 4 && + isinf (near_endpoints[2].d) && + near_endpoints[0].p.x == near_endpoints[3].p.x && + near_endpoints[0].p.y == near_endpoints[3].p.y) + { + glyphy_arc_endpoint_t e0, e1, e2; + e0 = near_endpoints[2]; + e1 = near_endpoints[3]; + e2 = near_endpoints[1]; + near_endpoints.resize (0); + near_endpoints.push_back (e0); + near_endpoints.push_back (e1); + near_endpoints.push_back (e2); + } + + for (unsigned i = 0; i < near_endpoints.size (); i++) { + glyphy_arc_endpoint_t &endpoint = near_endpoints[i]; + tex_data.push_back (arc_endpoint_encode (QUANTIZE_X(endpoint.p.x), QUANTIZE_Y(endpoint.p.y), endpoint.d)); + } + + unsigned int current_endpoints = tex_data.size () - offset; + + /* See if we can fulfill this cell by using already-encoded arcs */ + const glyphy_rgba_t *needle = &tex_data[offset]; + unsigned int needle_len = current_endpoints; + const glyphy_rgba_t *haystack = &tex_data[header_length]; + unsigned int haystack_len = offset - header_length; + + bool found = false; + if (needle_len) + while (haystack_len >= needle_len) { + /* Trick: we don't care about first endpoint's d value, so skip one + * byte in comparison. This works because arc_encode() packs the + * d value in the first byte. */ + if (0 == memcmp (1 + (const char *) needle, + 1 + (const char *) haystack, + needle_len * sizeof (*needle) - 1)) { + found = true; + break; + } + haystack++; + haystack_len--; + } + if (found) { + tex_data.resize (offset); + offset = haystack - &tex_data[0]; + } + + tex_data[row * grid_w + col] = arc_list_encode (offset, current_endpoints, side); + offset = tex_data.size (); + + total_arcs += current_endpoints; + } + + if (avg_fetch_achieved) + *avg_fetch_achieved = 1 + double (total_arcs) / (grid_w * grid_h); + + *pextents = extents; + + if (tex_data.size () > blob_size) + return false; + + memcpy (blob, &tex_data[0], tex_data.size () * sizeof(tex_data[0])); + *output_len = tex_data.size (); + *nominal_width = grid_w; + *nominal_height = grid_h; + + return true; +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common.glsl avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common.glsl --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common.glsl 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common.glsl 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,222 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju + */ + + +#ifndef GLYPHY_INFINITY +# define GLYPHY_INFINITY 1e9 +#endif +#ifndef GLYPHY_EPSILON +# define GLYPHY_EPSILON 1e-5 +#endif + +#ifndef GLYPHY_RGBA +# ifdef GLYPHY_BGRA +# define GLYPHY_RGBA(v) glyphy_bgra (v) +# else +# define GLYPHY_RGBA(v) glyphy_rgba (v) +# endif +#endif + +vec4 +glyphy_rgba (const vec4 v) +{ + return v.rgba; +} + +vec4 +glyphy_bgra (const vec4 v) +{ + return v.bgra; +} + + +struct glyphy_arc_t { + vec2 p0; + vec2 p1; + float d; +}; + +struct glyphy_arc_endpoint_t { + /* Second arc endpoint */ + vec2 p; + /* Infinity if this endpoint does not form an arc with the previous + * endpoint. Ie. a "move_to". Test with glyphy_isinf(). + * Arc depth otherwise. */ + float d; +}; + +struct glyphy_arc_list_t { + /* Number of endpoints in the list. + * Will be zero if we're far away inside or outside, in which case side is set. + * Will be -1 if this arc-list encodes a single line, in which case line_* are set. */ + int num_endpoints; + + /* If num_endpoints is zero, this specifies whether we are inside (-1) + * or outside (+1). Otherwise we're unsure (0). */ + int side; + /* Offset to the arc-endpoints from the beginning of the glyph blob */ + int offset; + + /* A single line is all we care about. It's right here. */ + float line_angle; + float line_distance; /* From nominal glyph center */ +}; + +bool +glyphy_isinf (const float v) +{ + return abs (v) >= GLYPHY_INFINITY * .5; +} + +bool +glyphy_iszero (const float v) +{ + return abs (v) <= GLYPHY_EPSILON * 2.; +} + +vec2 +glyphy_ortho (const vec2 v) +{ + return vec2 (-v.y, v.x); +} + +int +glyphy_float_to_byte (const float v) +{ + return int (v * (256. - GLYPHY_EPSILON)); +} + +ivec4 +glyphy_vec4_to_bytes (const vec4 v) +{ + return ivec4 (v * (256. - GLYPHY_EPSILON)); +} + +ivec2 +glyphy_float_to_two_nimbles (const float v) +{ + int f = glyphy_float_to_byte (v); + return ivec2 (f / 16, int(mod (float(f), 16.))); +} + +/* returns tan (2 * atan (d)) */ +float +glyphy_tan2atan (const float d) +{ + return 2. * d / (1. - d * d); +} + +glyphy_arc_endpoint_t +glyphy_arc_endpoint_decode (const vec4 v, const ivec2 nominal_size) +{ + vec2 p = (vec2 (glyphy_float_to_two_nimbles (v.a)) + v.gb) / 16.; + float d = v.r; + if (d == 0.) + d = GLYPHY_INFINITY; + else +#define GLYPHY_MAX_D .5 + d = float(glyphy_float_to_byte (d) - 128) * GLYPHY_MAX_D / 127.; +#undef GLYPHY_MAX_D + return glyphy_arc_endpoint_t (p * vec2(nominal_size), d); +} + +vec2 +glyphy_arc_center (const glyphy_arc_t a) +{ + return mix (a.p0, a.p1, .5) + + glyphy_ortho (a.p1 - a.p0) / (2. * glyphy_tan2atan (a.d)); +} + +bool +glyphy_arc_wedge_contains (const glyphy_arc_t a, const vec2 p) +{ + float d2 = glyphy_tan2atan (a.d); + return dot (p - a.p0, (a.p1 - a.p0) * mat2(1, d2, -d2, 1)) >= 0. && + dot (p - a.p1, (a.p1 - a.p0) * mat2(1, -d2, d2, 1)) <= 0.; +} + +float +glyphy_arc_wedge_signed_dist_shallow (const glyphy_arc_t a, const vec2 p) +{ + vec2 v = normalize (a.p1 - a.p0); + float line_d = dot (p - a.p0, glyphy_ortho (v)); + if (a.d == 0.) + return line_d; + + float d0 = dot ((p - a.p0), v); + if (d0 < 0.) + return sign (line_d) * distance (p, a.p0); + float d1 = dot ((a.p1 - p), v); + if (d1 < 0.) + return sign (line_d) * distance (p, a.p1); + float r = 2. * a.d * (d0 * d1) / (d0 + d1); + if (r * line_d > 0.) + return sign (line_d) * min (abs (line_d + r), min (distance (p, a.p0), distance (p, a.p1))); + return line_d + r; +} + +float +glyphy_arc_wedge_signed_dist (const glyphy_arc_t a, const vec2 p) +{ + if (abs (a.d) <= .03) + return glyphy_arc_wedge_signed_dist_shallow (a, p); + vec2 c = glyphy_arc_center (a); + return sign (a.d) * (distance (a.p0, c) - distance (p, c)); +} + +float +glyphy_arc_extended_dist (const glyphy_arc_t a, const vec2 p) +{ + /* Note: this doesn't handle points inside the wedge. */ + vec2 m = mix (a.p0, a.p1, .5); + float d2 = glyphy_tan2atan (a.d); + if (dot (p - m, a.p1 - m) < 0.) + return dot (p - a.p0, normalize ((a.p1 - a.p0) * mat2(+d2, -1, +1, +d2))); + else + return dot (p - a.p1, normalize ((a.p1 - a.p0) * mat2(-d2, -1, +1, -d2))); +} + +int +glyphy_arc_list_offset (const vec2 p, const ivec2 nominal_size) +{ + ivec2 cell = ivec2 (clamp (floor (p), vec2 (0.,0.), vec2(nominal_size - 1))); + return cell.y * nominal_size.x + cell.x; +} + +glyphy_arc_list_t +glyphy_arc_list_decode (const vec4 v, const ivec2 nominal_size) +{ + glyphy_arc_list_t l; + ivec4 iv = glyphy_vec4_to_bytes (v); + l.side = 0; /* unsure */ + if (iv.r == 0) { /* arc-list encoded */ + l.offset = (iv.g * 256) + iv.b; + l.num_endpoints = iv.a; + if (l.num_endpoints == 255) { + l.num_endpoints = 0; + l.side = -1; + } else if (l.num_endpoints == 0) + l.side = +1; + } else { /* single line encoded */ + l.num_endpoints = -1; + l.line_distance = float(((iv.r - 128) * 256 + iv.g) - 0x4000) / float (0x1FFF) + * max (float (nominal_size.x), float (nominal_size.y)); + l.line_angle = float(-((iv.b * 256 + iv.a) - 0x8000)) / float (0x7FFF) * 3.14159265358979; + } + return l; +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common-glsl.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common-glsl.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common-glsl.h 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common-glsl.h 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,224 @@ +static const char *glyphy_common_glsl = +"/*\n" +" * Copyright 2012 Google, Inc. All Rights Reserved.\n" +" *\n" +" * Licensed under the Apache License, Version 2.0 (the \"License\");\n" +" * you may not use this file except in compliance with the License.\n" +" * You may obtain a copy of the License at\n" +" *\n" +" * http://www.apache.org/licenses/LICENSE-2.0\n" +" *\n" +" * Unless required by applicable law or agreed to in writing, software\n" +" * distributed under the License is distributed on an \"AS IS\" BASIS,\n" +" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +" * See the License for the specific language governing permissions and\n" +" * limitations under the License.\n" +" *\n" +" * Google Author(s): Behdad Esfahbod, Maysum Panju\n" +" */\n" +"\n" +"\n" +"#ifndef GLYPHY_INFINITY\n" +"# define GLYPHY_INFINITY 1e9\n" +"#endif\n" +"#ifndef GLYPHY_EPSILON\n" +"# define GLYPHY_EPSILON 1e-5\n" +"#endif\n" +"\n" +"#ifndef GLYPHY_RGBA\n" +"# ifdef GLYPHY_BGRA\n" +"# define GLYPHY_RGBA(v) glyphy_bgra (v)\n" +"# else\n" +"# define GLYPHY_RGBA(v) glyphy_rgba (v)\n" +"# endif\n" +"#endif\n" +"\n" +"vec4\n" +"glyphy_rgba (const vec4 v)\n" +"{\n" +" return v.rgba;\n" +"}\n" +"\n" +"vec4\n" +"glyphy_bgra (const vec4 v)\n" +"{\n" +" return v.bgra;\n" +"}\n" +"\n" +"\n" +"struct glyphy_arc_t {\n" +" vec2 p0;\n" +" vec2 p1;\n" +" float d;\n" +"};\n" +"\n" +"struct glyphy_arc_endpoint_t {\n" +" /* Second arc endpoint */\n" +" vec2 p;\n" +" /* Infinity if this endpoint does not form an arc with the previous\n" +" * endpoint. Ie. a \"move_to\". Test with glyphy_isinf().\n" +" * Arc depth otherwise. */\n" +" float d;\n" +"};\n" +"\n" +"struct glyphy_arc_list_t {\n" +" /* Number of endpoints in the list.\n" +" * Will be zero if we're far away inside or outside, in which case side is set.\n" +" * Will be -1 if this arc-list encodes a single line, in which case line_* are set. */\n" +" int num_endpoints;\n" +"\n" +" /* If num_endpoints is zero, this specifies whether we are inside (-1)\n" +" * or outside (+1). Otherwise we're unsure (0). */\n" +" int side;\n" +" /* Offset to the arc-endpoints from the beginning of the glyph blob */\n" +" int offset;\n" +"\n" +" /* A single line is all we care about. It's right here. */\n" +" float line_angle;\n" +" float line_distance; /* From nominal glyph center */\n" +"};\n" +"\n" +"bool\n" +"glyphy_isinf (const float v)\n" +"{\n" +" return abs (v) >= GLYPHY_INFINITY * .5;\n" +"}\n" +"\n" +"bool\n" +"glyphy_iszero (const float v)\n" +"{\n" +" return abs (v) <= GLYPHY_EPSILON * 2.;\n" +"}\n" +"\n" +"vec2\n" +"glyphy_ortho (const vec2 v)\n" +"{\n" +" return vec2 (-v.y, v.x);\n" +"}\n" +"\n" +"int\n" +"glyphy_float_to_byte (const float v)\n" +"{\n" +" return int (v * (256. - GLYPHY_EPSILON));\n" +"}\n" +"\n" +"ivec4\n" +"glyphy_vec4_to_bytes (const vec4 v)\n" +"{\n" +" return ivec4 (v * (256. - GLYPHY_EPSILON));\n" +"}\n" +"\n" +"ivec2\n" +"glyphy_float_to_two_nimbles (const float v)\n" +"{\n" +" int f = glyphy_float_to_byte (v);\n" +" return ivec2 (f / 16, int(mod (float(f), 16.)));\n" +"}\n" +"\n" +"/* returns tan (2 * atan (d)) */\n" +"float\n" +"glyphy_tan2atan (const float d)\n" +"{\n" +" return 2. * d / (1. - d * d);\n" +"}\n" +"\n" +"glyphy_arc_endpoint_t\n" +"glyphy_arc_endpoint_decode (const vec4 v, const ivec2 nominal_size)\n" +"{\n" +" vec2 p = (vec2 (glyphy_float_to_two_nimbles (v.a)) + v.gb) / 16.;\n" +" float d = v.r;\n" +" if (d == 0.)\n" +" d = GLYPHY_INFINITY;\n" +" else\n" +"#define GLYPHY_MAX_D .5\n" +" d = float(glyphy_float_to_byte (d) - 128) * GLYPHY_MAX_D / 127.;\n" +"#undef GLYPHY_MAX_D\n" +" return glyphy_arc_endpoint_t (p * vec2(nominal_size), d);\n" +"}\n" +"\n" +"vec2\n" +"glyphy_arc_center (const glyphy_arc_t a)\n" +"{\n" +" return mix (a.p0, a.p1, .5) +\n" +" glyphy_ortho (a.p1 - a.p0) / (2. * glyphy_tan2atan (a.d));\n" +"}\n" +"\n" +"bool\n" +"glyphy_arc_wedge_contains (const glyphy_arc_t a, const vec2 p)\n" +"{\n" +" float d2 = glyphy_tan2atan (a.d);\n" +" return dot (p - a.p0, (a.p1 - a.p0) * mat2(1, d2, -d2, 1)) >= 0. &&\n" +" dot (p - a.p1, (a.p1 - a.p0) * mat2(1, -d2, d2, 1)) <= 0.;\n" +"}\n" +"\n" +"float\n" +"glyphy_arc_wedge_signed_dist_shallow (const glyphy_arc_t a, const vec2 p)\n" +"{\n" +" vec2 v = normalize (a.p1 - a.p0);\n" +" float line_d = dot (p - a.p0, glyphy_ortho (v));\n" +" if (a.d == 0.)\n" +" return line_d;\n" +"\n" +" float d0 = dot ((p - a.p0), v);\n" +" if (d0 < 0.)\n" +" return sign (line_d) * distance (p, a.p0);\n" +" float d1 = dot ((a.p1 - p), v);\n" +" if (d1 < 0.)\n" +" return sign (line_d) * distance (p, a.p1);\n" +" float r = 2. * a.d * (d0 * d1) / (d0 + d1);\n" +" if (r * line_d > 0.)\n" +" return sign (line_d) * min (abs (line_d + r), min (distance (p, a.p0), distance (p, a.p1)));\n" +" return line_d + r;\n" +"}\n" +"\n" +"float\n" +"glyphy_arc_wedge_signed_dist (const glyphy_arc_t a, const vec2 p)\n" +"{\n" +" if (abs (a.d) <= .03)\n" +" return glyphy_arc_wedge_signed_dist_shallow (a, p);\n" +" vec2 c = glyphy_arc_center (a);\n" +" return sign (a.d) * (distance (a.p0, c) - distance (p, c));\n" +"}\n" +"\n" +"float\n" +"glyphy_arc_extended_dist (const glyphy_arc_t a, const vec2 p)\n" +"{\n" +" /* Note: this doesn't handle points inside the wedge. */\n" +" vec2 m = mix (a.p0, a.p1, .5);\n" +" float d2 = glyphy_tan2atan (a.d);\n" +" if (dot (p - m, a.p1 - m) < 0.)\n" +" return dot (p - a.p0, normalize ((a.p1 - a.p0) * mat2(+d2, -1, +1, +d2)));\n" +" else\n" +" return dot (p - a.p1, normalize ((a.p1 - a.p0) * mat2(-d2, -1, +1, -d2)));\n" +"}\n" +"\n" +"int\n" +"glyphy_arc_list_offset (const vec2 p, const ivec2 nominal_size)\n" +"{\n" +" ivec2 cell = ivec2 (clamp (floor (p), vec2 (0.,0.), vec2(nominal_size - 1)));\n" +" return cell.y * nominal_size.x + cell.x;\n" +"}\n" +"\n" +"glyphy_arc_list_t\n" +"glyphy_arc_list_decode (const vec4 v, const ivec2 nominal_size)\n" +"{\n" +" glyphy_arc_list_t l;\n" +" ivec4 iv = glyphy_vec4_to_bytes (v);\n" +" l.side = 0; /* unsure */\n" +" if (iv.r == 0) { /* arc-list encoded */\n" +" l.offset = (iv.g * 256) + iv.b;\n" +" l.num_endpoints = iv.a;\n" +" if (l.num_endpoints == 255) {\n" +" l.num_endpoints = 0;\n" +" l.side = -1;\n" +" } else if (l.num_endpoints == 0)\n" +" l.side = +1;\n" +" } else { /* single line encoded */\n" +" l.num_endpoints = -1;\n" +" l.line_distance = float(((iv.r - 128) * 256 + iv.g) - 0x4000) / float (0x1FFF)\n" +" * max (float (nominal_size.x), float (nominal_size.y));\n" +" l.line_angle = float(-((iv.b * 256 + iv.a) - 0x8000)) / float (0x7FFF) * 3.14159265358979;\n" +" }\n" +" return l;\n" +"}\n" +; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common.hh avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common.hh --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common.hh 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-common.hh 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,59 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju + */ + +#ifndef GLYPHY_COMMON_HH +#define GLYPHY_COMMON_HH + +#include + +#include +#include +#include +#include +#include +#include + +#ifndef GLYPHY_EPSILON +# define GLYPHY_EPSILON 1e-5 +#endif +#ifndef GLYPHY_INFINITY +# define GLYPHY_INFINITY INFINITY +#endif + + +static inline bool +iszero (double v) +{ + return fabs (v) < 2 * GLYPHY_EPSILON; +} + + +#define GLYPHY_MAX_D .5 + +#undef ARRAY_LENGTH +#define ARRAY_LENGTH(__array) ((signed int) (sizeof (__array) / sizeof (__array[0]))) + +#define _ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1] +#define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond)) +#define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond)) + +#ifdef __ANDROID__ +#define log2(x) (log(x) / log(2.0)) +#endif + +#endif /* GLYPHY_COMMON_HH */ diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-extents.cc avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-extents.cc --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-extents.cc 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-extents.cc 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,89 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "glyphy-common.hh" + + +void +glyphy_extents_clear (glyphy_extents_t *extents) +{ + extents->min_x = GLYPHY_INFINITY; + extents->min_y = GLYPHY_INFINITY; + extents->max_x = -GLYPHY_INFINITY; + extents->max_y = -GLYPHY_INFINITY; +} + +glyphy_bool_t +glyphy_extents_is_empty (const glyphy_extents_t *extents) +{ + return isinf (extents->min_x); +} + +void +glyphy_extents_add (glyphy_extents_t *extents, + const glyphy_point_t *p) +{ + if (glyphy_extents_is_empty (extents)) { + extents->min_x = extents->max_x = p->x; + extents->min_y = extents->max_y = p->y; + return; + } + extents->min_x = std::min (extents->min_x, p->x); + extents->min_y = std::min (extents->min_y, p->y); + extents->max_x = std::max (extents->max_x, p->x); + extents->max_y = std::max (extents->max_y, p->y); +} + +void +glyphy_extents_extend (glyphy_extents_t *extents, + const glyphy_extents_t *other) +{ + if (glyphy_extents_is_empty (other)) + return; + if (glyphy_extents_is_empty (extents)) { + *extents = *other; + return; + } + extents->min_x = std::min (extents->min_x, other->min_x); + extents->min_y = std::min (extents->min_y, other->min_y); + extents->max_x = std::max (extents->max_x, other->max_x); + extents->max_y = std::max (extents->max_y, other->max_y); +} + +glyphy_bool_t +glyphy_extents_includes (const glyphy_extents_t *extents, + const glyphy_point_t *p) +{ + return extents->min_x <= p->x && p->x <= extents->max_x && + extents->min_y <= p->y && p->y <= extents->max_y; +} + +void +glyphy_extents_scale (glyphy_extents_t *extents, + double x_scale, + double y_scale) +{ + extents->min_x *= x_scale; + extents->max_x *= x_scale; + extents->min_y *= y_scale; + extents->max_y *= y_scale; +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-freetype.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-freetype.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-freetype.h 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-freetype.h 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,93 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju + */ + +/* Intentionally doesn't have include guards */ + +#include "glyphy.h" + +#include +#include FT_FREETYPE_H +#include FT_OUTLINE_H + + + +#ifndef GLYPHY_FREETYPE_PREFIX +#define GLYPHY_FREETYPE_PREFIX glyphy_freetype_ +#endif + +#ifndef glyphy_freetype +#define glyphy_freetype(name) GLYPHY_PASTE (GLYPHY_FREETYPE_PREFIX, name) +#endif + + + +static int +glyphy_freetype(move_to) (FT_Vector *to, + glyphy_arc_accumulator_t *acc) +{ + glyphy_point_t p1 = {to->x, to->y}; + glyphy_arc_accumulator_close_path (acc); + glyphy_arc_accumulator_move_to (acc, &p1); + return glyphy_arc_accumulator_successful (acc) ? FT_Err_Ok : FT_Err_Out_Of_Memory; +} + +static int +glyphy_freetype(line_to) (FT_Vector *to, + glyphy_arc_accumulator_t *acc) +{ + glyphy_point_t p1 = {to->x, to->y}; + glyphy_arc_accumulator_line_to (acc, &p1); + return glyphy_arc_accumulator_successful (acc) ? FT_Err_Ok : FT_Err_Out_Of_Memory; +} + +static int +glyphy_freetype(conic_to) (FT_Vector *control, FT_Vector *to, + glyphy_arc_accumulator_t *acc) +{ + glyphy_point_t p1 = {control->x, control->y}; + glyphy_point_t p2 = {to->x, to->y}; + glyphy_arc_accumulator_conic_to (acc, &p1, &p2); + return glyphy_arc_accumulator_successful (acc) ? FT_Err_Ok : FT_Err_Out_Of_Memory; +} + +static int +glyphy_freetype(cubic_to) (FT_Vector *control1, FT_Vector *control2, FT_Vector *to, + glyphy_arc_accumulator_t *acc) +{ + glyphy_point_t p1 = {control1->x, control1->y}; + glyphy_point_t p2 = {control2->x, control2->y}; + glyphy_point_t p3 = {to->x, to->y}; + glyphy_arc_accumulator_cubic_to (acc, &p1, &p2, &p3); + return glyphy_arc_accumulator_successful (acc) ? FT_Err_Ok : FT_Err_Out_Of_Memory; +} + +static FT_Error +glyphy_freetype(outline_decompose) (const FT_Outline *outline, + glyphy_arc_accumulator_t *acc) +{ + const FT_Outline_Funcs outline_funcs = { + (FT_Outline_MoveToFunc) glyphy_freetype(move_to), + (FT_Outline_LineToFunc) glyphy_freetype(line_to), + (FT_Outline_ConicToFunc) glyphy_freetype(conic_to), + (FT_Outline_CubicToFunc) glyphy_freetype(cubic_to), + 0, /* shift */ + 0, /* delta */ + }; + + return FT_Outline_Decompose ((FT_Outline *) outline, &outline_funcs, acc); +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-geometry.hh avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-geometry.hh --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-geometry.hh 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-geometry.hh 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,713 @@ +/* + * Copyright 2012,2013 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju + */ + +#ifndef GLYPHY_GEOMETRY_HH +#define GLYPHY_GEOMETRY_HH + +#include "glyphy-common.hh" + +namespace GLyphy { +namespace Geometry { + +template struct Pair; +struct Vector; +struct SignedVector; +struct Point; +struct Line; +struct Segment; +struct Arc; +struct Bezier; + +/* returns tan (2 * atan (d)) */ +inline double tan2atan (double d) { return 2 * d / (1 - d*d); } + +/* returns sin (2 * atan (d)) */ +inline double sin2atan (double d) { return 2 * d / (1 + d*d); } + +/* returns cos (2 * atan (d)) */ +inline double cos2atan (double d) { return (1 - d*d) / (1 + d*d); } + +template +struct Pair { + typedef Type ElementType; + + inline Pair (const Type &first_, const Type &second_) : first (first_), second (second_) {} + + Type first, second; +}; + +struct Point : glyphy_point_t { + inline Point (double x_, double y_) { x = x_; y = y_; } + inline explicit Point (const Vector &v); + inline Point (const glyphy_point_t &p) { *(glyphy_point_t *)this = p; } + + inline bool operator == (const Point &p) const; + inline bool operator != (const Point &p) const; + inline Point& operator+= (const Vector &v); + inline Point& operator-= (const Vector &v); + inline const Point operator+ (const Vector &v) const; + inline const Point operator- (const Vector &v) const; + inline const Vector operator- (const Point &p) const; + inline const Point midpoint (const Point &p) const; + inline const Line bisector (const Point &p) const; + inline double distance_to_point (const Point &p) const; /* distance to point! */ + inline double squared_distance_to_point (const Point &p) const; /* square of distance to point! */ + + inline bool is_finite (void) const; + inline const Point lerp (const double &a, const Point &p) const; +}; + +struct Vector { + inline Vector (double dx_, double dy_) : dx (dx_), dy (dy_) {} + inline explicit Vector (const Point &p) : dx (p.x), dy (p.y) {} + + inline bool operator == (const Vector &v) const; + inline bool operator != (const Vector &v) const; + inline const Vector operator+ (void) const; + inline const Vector operator- (void) const; + inline Vector& operator+= (const Vector &v); + inline Vector& operator-= (const Vector &v); + inline Vector& operator*= (const double &s); + inline Vector& operator/= (const double &s); + inline const Vector operator+ (const Vector &v) const; + inline const Vector operator- (const Vector &v) const; + inline const Vector operator* (const double &s) const; + inline const Vector operator/ (const double &s) const; + inline double operator* (const Vector &v) const; /* dot product */ + inline const Point operator+ (const Point &p) const; + + inline bool is_nonzero (void) const; + inline double len (void) const; + inline double len2 (void) const; + inline const Vector normalized (void) const; + inline const Vector ortho (void) const; + inline const Vector normal (void) const; /* ortho().normalized() */ + inline double angle (void) const; + + inline const Vector rebase (const Vector &bx, const Vector &by) const; + inline const Vector rebase (const Vector &bx) const; + + double dx, dy; +}; + +struct SignedVector : Vector { + inline SignedVector (const Vector &v, bool negative_) : Vector (v), negative (negative_) {} + + inline bool operator == (const SignedVector &v) const; + inline bool operator != (const SignedVector &v) const; + inline const SignedVector operator- (void) const; + + bool negative; +}; + +struct Line { + inline Line (double a_, double b_, double c_) : n (a_, b_), c (c_) {} + inline Line (Vector n_, double c_) : n (n_), c (c_) {} + inline Line (const Point &p0, const Point &p1) : + n ((p1 - p0).ortho ()), c (n * Vector (p0)) {} + + inline const Point operator+ (const Line &l) const; /* line intersection! */ + inline const SignedVector operator- (const Point &p) const; /* shortest vector from point to line */ + + + inline const Line normalized (void) const; + inline const Vector normal (void) const; + + Vector n; /* line normal */ + double c; /* n.dx*x + n.dy*y = c */ +}; + +struct Segment { + inline Segment (const Point &p0_, const Point &p1_) : + p0 (p0_), p1 (p1_) {} + + inline const SignedVector operator- (const Point &p) const; /* shortest vector from point to ***line*** */ + inline double distance_to_point (const Point &p) const; /* shortest distance from point to segment */ + inline double squared_distance_to_point (const Point &p) const; /* shortest distance squared from point to segment */ + inline bool contains_in_span (const Point &p) const; /* is p in the stripe formed by sliding this segment? */ + inline double max_distance_to_arc (const Arc &a) const; + + + Point p0; + Point p1; +}; + + + +struct Arc { + inline Arc (const Point &p0_, const Point &p1_, const Point &pm, bool complement) : + p0 (p0_), p1 (p1_), + d (p0_ == pm || p1_ == pm ? 0 : + tan (((p1_-pm).angle () - (p0_-pm).angle ()) / 2 - (complement ? 0 : M_PI_2))) {} + inline Arc (const Point &p0_, const Point &p1_, const double &d_) : + p0 (p0_), p1 (p1_), d (d_) {} + inline Arc (const Point ¢er, double radius, const double &a0, const double &a1, bool complement) : + p0 (center + Vector (cos(a0),sin(a0)) * radius), + p1 (center + Vector (cos(a1),sin(a1)) * radius), + d (tan ((a1 - a0) / 4 - (complement ? 0 : M_PI_2))) {} + inline Arc (const glyphy_arc_t &a) : p0 (a.p0), p1 (a.p1), d (a.d) {} + inline operator glyphy_arc_t (void) const { glyphy_arc_t a = {p0, p1, d}; return a; } + + inline bool operator == (const Arc &a) const; + inline bool operator != (const Arc &a) const; + inline const SignedVector operator- (const Point &p) const; /* shortest vector from point to arc */ + + inline double radius (void) const; + inline const Point center (void) const; + inline const Pair tangents (void) const; + + inline Bezier approximate_bezier (double *error) const; + + inline bool wedge_contains_point (const Point &p) const; + inline double distance_to_point (const Point &p) const; + inline double squared_distance_to_point (const Point &p) const; + inline double extended_dist (const Point &p) const; + + inline void extents (glyphy_extents_t &extents) const; + + Point p0, p1; + double d; /* Depth */ +}; + +struct Bezier { + inline Bezier (const Point &p0_, const Point &p1_, + const Point &p2_, const Point &p3_) : + p0 (p0_), p1 (p1_), p2 (p2_), p3 (p3_) {} + + inline const Point point (const double &t) const; + inline const Point midpoint (void) const; + inline const Vector tangent (const double &t) const; + inline const Vector d_tangent (const double &t) const; + inline double curvature (const double &t) const; + inline const Pair split (const double &t) const; + inline const Pair halve (void) const; + inline const Bezier segment (const double &t0, const double &t1) const; + + Point p0, p1, p2, p3; +}; + + +/* Implementations */ + + +/* Point */ + +inline Point::Point (const Vector &v) { + x = v.dx; + y = v.dy; +} +inline bool Point::operator == (const Point &p) const { + return x == p.x && y == p.y; +} +inline bool Point::operator != (const Point &p) const { + return !(*this == p); +} +inline Point& Point::operator+= (const Vector &v) { + x += v.dx; + y += v.dy; + return *this; +} +inline Point& Point::operator-= (const Vector &v) { + x -= v.dx; + y -= v.dy; + return *this; +} +inline const Point Point::operator+ (const Vector &v) const { + return Point (*this) += v; +} +inline const Point Point::operator- (const Vector &v) const { + return Point (*this) -= v; +} +inline const Vector Point::operator- (const Point &p) const { + return Vector (x - p.x, y - p.y); +} + +inline const Point Point::midpoint (const Point &p) const { + return *this + (p - *this) / 2; +} +inline const Line Point::bisector (const Point &p) const { + Vector d = p - *this; + return Line (d.dx * 2, d.dy * 2, d * Vector (p) + d * Vector (*this)); +} + +inline double Point::distance_to_point (const Point &p) const { + return ((*this) - p).len (); +} + +inline double Point::squared_distance_to_point (const Point &p) const { + return ((*this) - p).len2 (); +} + +inline bool Point::is_finite (void) const { + return isfinite (x) && isfinite (y); +} +inline const Point Point::lerp (const double &a, const Point &p) const { + /* The following two cases are special-cased to get better floating + * point stability. We require that points that are the same be + * bit-equal. */ + if (a == 0) return *this; + if (a == 1.0) return p; + return Point ((1-a) * x + a * p.x, (1-a) * y + a * p.y); +} + + +/* Vector */ + +inline bool Vector::operator == (const Vector &v) const { + return dx == v.dx && dy == v.dy; +} +inline bool Vector::operator != (const Vector &v) const { + return !(*this == v); +} +inline const Vector Vector::operator+ (void) const { + return *this; +} +inline const Vector Vector::operator- (void) const { + return Vector (-dx, -dy); +} +inline Vector& Vector::operator+= (const Vector &v) { + dx += v.dx; + dy += v.dy; + return *this; +} +inline Vector& Vector::operator-= (const Vector &v) { + dx -= v.dx; + dy -= v.dy; + return *this; +} +inline Vector& Vector::operator*= (const double &s) { + dx *= s; + dy *= s; + return *this; +} +inline Vector& Vector::operator/= (const double &s) { + dx /= s; + dy /= s; + return *this; +} +inline const Vector Vector::operator+ (const Vector &v) const { + return Vector (*this) += v; +} +inline const Vector Vector::operator- (const Vector &v) const { + return Vector (*this) -= v; +} +inline const Vector Vector::operator* (const double &s) const { + return Vector (*this) *= s; +} +inline const Vector operator* (const double &s, const Vector &v) { + return v * s; +} +inline const Vector Vector::operator/ (const double &s) const { + return Vector (*this) /= s; +} +inline double Vector::operator* (const Vector &v) const { /* dot product */ + return dx * v.dx + dy * v.dy; +} +inline const Point Vector::operator+ (const Point &p) const { + return p + *this; +} + +inline bool Vector::is_nonzero (void) const { + return dx || dy; +} +inline double Vector::len (void) const { + return hypot (dx, dy); +} +inline double Vector::len2 (void) const { + return dx * dx + dy * dy; +} +inline const Vector Vector::normalized (void) const { + double d = len (); + return d ? *this / d : *this; +} +inline const Vector Vector::ortho (void) const { + return Vector (-dy, dx); +} +inline const Vector Vector::normal (void) const { + return ortho ().normalized (); +} +inline double Vector::angle (void) const { + return atan2 (dy, dx); +} + +inline const Vector Vector::rebase (const Vector &bx, + const Vector &by) const { + return Vector (*this * bx, *this * by); +} +inline const Vector Vector::rebase (const Vector &bx) const { + return rebase (bx, bx.ortho ()); +} + + +/* SignedVector */ + +inline bool SignedVector::operator == (const SignedVector &v) const { + return (const Vector &)(*this) == (const Vector &)(v) && negative == v.negative; +} +inline bool SignedVector::operator != (const SignedVector &v) const { + return !(*this == v); +} +inline const SignedVector SignedVector::operator- (void) const { + return SignedVector (-(const Vector &)(*this), !negative); +} + + +/* Line */ + +inline const Point Line::operator+ (const Line &l) const { + double det = n.dx * l.n.dy - n.dy * l.n.dx; + if (!det) + return Point (GLYPHY_INFINITY, GLYPHY_INFINITY); + return Point ((c * l.n.dy - n.dy * l.c) / det, + (n.dx * l.c - c * l.n.dx) / det); +} +inline const SignedVector Line::operator- (const Point &p) const { + double mag = -(n * Vector (p) - c) / n.len (); + return SignedVector (n.normalized () * mag, mag < 0); /******************************************************************************************* FIX. *************************************/ +} + +inline const SignedVector operator- (const Point &p, const Line &l) { + return -(l - p); +} + +inline const Line Line::normalized (void) const { + double d = n.len (); + return d ? Line (n / d, c / d) : *this; +} +inline const Vector Line::normal (void) const { + return n; +} + +/* Segment */ +inline const SignedVector Segment::operator- (const Point &p) const { + /* shortest vector from point to line */ + return p - Line (p1, p0); /************************************************************************************************** Should the order (p1, p0) depend on d?? ***********************/ +} + +/* Segment */ +inline bool Segment::contains_in_span (const Point &p) const { + if (p0 == p1) + return false; + + /* shortest vector from point to line */ + Line temp (p0, p1); + double mag = -(temp.n * Vector (p) - temp.c) / temp.n.len (); + Vector y (temp.n.normalized () * mag); + Point z = y + p; + + // Check if z is between p0 and p1. + + if (fabs (p1.y - p0.y) > fabs (p1.x - p0.x)) { + return ((z.y - p0.y > 0 && p1.y - p0.y > z.y - p0.y) || + (z.y - p0.y < 0 && p1.y - p0.y < z.y - p0.y)); + } + else { + return ((0 < z.x - p0.x && z.x - p0.x < p1.x - p0.x) || + (0 > z.x - p0.x && z.x - p0.x > p1.x - p0.x)); + } +} + +inline double Segment::distance_to_point (const Point &p) const { + if (p0 == p1) + return 0; + + // Check if z is between p0 and p1. + Line temp (p0, p1); + if (contains_in_span (p)) + return -(temp.n * Vector (p) - temp.c) / temp.n.len (); + + double dist_p_p0 = p.distance_to_point (p0); + double dist_p_p1 = p.distance_to_point (p1); + return (dist_p_p0 < dist_p_p1 ? dist_p_p0 : dist_p_p1) * (-(temp.n * Vector (p) - temp.c) < 0 ? -1 : 1); +} + + +inline double Segment::squared_distance_to_point (const Point &p) const { + if (p0 == p1) + return 0; + + // Check if z is between p0 and p1. + Line temp (p0, p1); + if (contains_in_span (p)) + return (temp.n * Vector (p) - temp.c) * (temp.n * Vector (p) - temp.c) / (temp.n * temp.n); + + double dist_p_p0 = p.squared_distance_to_point (p0); + double dist_p_p1 = p.squared_distance_to_point (p1); + return (dist_p_p0 < dist_p_p1 ? dist_p_p0 : dist_p_p1); +} + + +inline double Segment::max_distance_to_arc (const Arc &a) const { + double max_distance = fabs(a.distance_to_point(p0)) ; + return max_distance > fabs(a.distance_to_point(p1)) ? max_distance : fabs(a.distance_to_point(p1)) ; +} + + + +/* Arc */ + +inline bool Arc::operator == (const Arc &a) const { + return p0 == a.p0 && p1 == a.p1 && d == a.d; +} +inline bool Arc::operator != (const Arc &a) const { + return !(*this == a); +} + + +inline const SignedVector Arc::operator- (const Point &p) const { + + if (fabs(d) < 1e-5) { + Segment arc_segment (p0, p1); + return arc_segment - p; + } + if (wedge_contains_point (p)){ + Vector difference = (center () - p).normalized () * fabs (p.distance_to_point (center ()) - radius ()); + + return SignedVector (difference, ((p - center ()).len () < radius ()) ^ (d < 0)); + } + double d0 = p.squared_distance_to_point (p0); + double d1 = p.squared_distance_to_point (p1); + + Arc other_arc (p0, p1, (1.0 + d) / (1.0 - d)); /********************************* NOT Robust. But works? *****************/ + Vector normal = center () - (d0 < d1 ? p0 : p1) ; + + if (normal.len() == 0) + return SignedVector (Vector (0, 0), true); /************************************ Check sign of this S.D. *************/ + + return SignedVector (Line (normal.dx, normal.dy, normal * Vector ((d0 < d1 ? p0 : p1))) - p, !other_arc.wedge_contains_point(p)); +} + +inline const SignedVector operator- (const Point &p, const Arc &a) { + return -(a - p); +} + + + +inline double Arc::radius (void) const +{ + return fabs ((p1 - p0).len () / (2 * sin2atan (d))); +} + +inline const Point Arc::center (void) const +{ + return (p0.midpoint (p1)) + (p1 - p0).ortho () / (2 * tan2atan (d)); +} + +inline const Pair Arc::tangents (void) const +{ + Vector dp = (p1 - p0) * .5; + Vector pp = dp.ortho () * -sin2atan (d); + dp = dp * cos2atan (d); + return Pair (dp + pp, dp - pp); +} + + + +inline Bezier Arc::approximate_bezier (double *error) const +{ + Vector dp = p1 - p0; + Vector pp = dp.ortho (); + + if (error) + *error = dp.len () * pow (fabs (d), 5) / (54 * (1 + d*d)); + + dp *= ((1 - d*d) / 3); + pp *= (2 * d / 3); + + Point p0s = p0 + dp - pp; + Point p1s = p1 - dp - pp; + + return Bezier (p0, p0s, p1s, p1); +} + + +inline bool Arc::wedge_contains_point (const Point &p) const +{ + Pair t = tangents (); + if (fabs (d) <= 1) + return (p - p0) * t.first >= 0 && (p - p1) * t.second <= 0; + else + return (p - p0) * t.first >= 0 || (p - p1) * t.second <= 0; +} + + +/* Distance may not always be positive, but will be to an endpoint whenever necessary. */ +inline double Arc::distance_to_point (const Point &p) const { + if (fabs(d) < 1e-5) { + Segment arc_segment (p0, p1); + return arc_segment.distance_to_point (p); + } + + SignedVector difference = *this - p; + + if (wedge_contains_point (p) && fabs(d) > 1e-5) + return fabs (p.distance_to_point (center ()) - radius ()) * (difference.negative ? -1 : 1); + double d1 = p.squared_distance_to_point (p0); + double d2 = p.squared_distance_to_point (p1); + return (d1 < d2 ? sqrt(d1) : sqrt(d2)) * (difference.negative ? -1 : 1); +} + +/* Distance will be to an endpoint whenever necessary. */ +inline double Arc::squared_distance_to_point (const Point &p) const { + if (fabs(d) < 1e-5) { + Segment arc_segment (p0, p1); + return arc_segment.squared_distance_to_point (p); + } + + //SignedVector difference = *this - p; + + if (wedge_contains_point (p) && fabs(d) > 1e-5) { + double answer = p.distance_to_point (center ()) - radius (); + return answer * answer; + } + double d1 = p.squared_distance_to_point (p0); + double d2 = p.squared_distance_to_point (p1); + return (d1 < d2 ? d1 : d2); +} + +inline double Arc::extended_dist (const Point &p) const { + Point m = p0.lerp (.5, p1); + Vector dp = p1 - p0; + Vector pp = dp.ortho (); + float d2 = tan2atan (d); + if ((p - m) * (p1 - m) < 0) + return (p - p0) * (pp + dp * d2).normalized (); + else + return (p - p1) * (pp - dp * d2).normalized (); +} + +inline void Arc::extents (glyphy_extents_t &extents) const { + glyphy_extents_clear (&extents); + glyphy_extents_add (&extents, &p0); + glyphy_extents_add (&extents, &p1); + Point c = center (); + double r = radius (); + Point p[4] = {c + r * Vector (-1, 0), + c + r * Vector (+1, 0), + c + r * Vector ( 0, -1), + c + r * Vector ( 0, +1)}; + for (unsigned int i = 0; i < 4; i++) + if (wedge_contains_point (p[i])) + glyphy_extents_add (&extents, &p[i]); +} + + +/* Bezier */ + +inline const Point Bezier::point (const double &t) const { + Point p01 = p0.lerp (t, p1); + Point p12 = p1.lerp (t, p2); + Point p23 = p2.lerp (t, p3); + Point p012 = p01.lerp (t, p12); + Point p123 = p12.lerp (t, p23); + Point p0123 = p012.lerp (t, p123); + return p0123; +} + +inline const Point Bezier::midpoint (void) const +{ + Point p01 = p0.midpoint (p1); + Point p12 = p1.midpoint (p2); + Point p23 = p2.midpoint (p3); + Point p012 = p01.midpoint (p12); + Point p123 = p12.midpoint (p23); + Point p0123 = p012.midpoint (p123); + return p0123; +} + +inline const Vector Bezier::tangent (const double &t) const +{ + double t_2_0 = t * t; + double t_0_2 = (1 - t) * (1 - t); + + double _1__4t_1_0_3t_2_0 = 1 - 4 * t + 3 * t_2_0; + double _2t_1_0_3t_2_0 = 2 * t - 3 * t_2_0; + + return Vector (-3 * p0.x * t_0_2 + +3 * p1.x * _1__4t_1_0_3t_2_0 + +3 * p2.x * _2t_1_0_3t_2_0 + +3 * p3.x * t_2_0, + -3 * p0.y * t_0_2 + +3 * p1.y * _1__4t_1_0_3t_2_0 + +3 * p2.y * _2t_1_0_3t_2_0 + +3 * p3.y * t_2_0); +} + +inline const Vector Bezier::d_tangent (const double &t) const { + return Vector (6 * ((-p0.x + 3*p1.x - 3*p2.x + p3.x) * t + (p0.x - 2*p1.x + p2.x)), + 6 * ((-p0.y + 3*p1.y - 3*p2.y + p3.y) * t + (p0.y - 2*p1.y + p2.y))); +} + +inline double Bezier::curvature (const double &t) const { + Vector dpp = tangent (t).ortho (); + Vector ddp = d_tangent (t); + /* normal vector len squared */ + double len = dpp.len (); + double curvature = (dpp * ddp) / (len * len * len); + return curvature; +} + +inline const Pair Bezier::split (const double &t) const { + Point p01 = p0.lerp (t, p1); + Point p12 = p1.lerp (t, p2); + Point p23 = p2.lerp (t, p3); + Point p012 = p01.lerp (t, p12); + Point p123 = p12.lerp (t, p23); + Point p0123 = p012.lerp (t, p123); + return Pair (Bezier (p0, p01, p012, p0123), + Bezier (p0123, p123, p23, p3)); +} + +inline const Pair Bezier::halve (void) const +{ + Point p01 = p0.midpoint (p1); + Point p12 = p1.midpoint (p2); + Point p23 = p2.midpoint (p3); + Point p012 = p01.midpoint (p12); + Point p123 = p12.midpoint (p23); + Point p0123 = p012.midpoint (p123); + return Pair (Bezier (p0, p01, p012, p0123), + Bezier (p0123, p123, p23, p3)); +} + +inline const Bezier Bezier::segment (const double &t0, const double &t1) const +{ + Point p01 = p0.lerp (t0, p1); + Point p12 = p1.lerp (t0, p2); + Point p23 = p2.lerp (t0, p3); + Point p012 = p01.lerp (t0, p12); + Point p123 = p12.lerp (t0, p23); + Point p0123 = p012.lerp (t0, p123); + + Point q01 = p0.lerp (t1, p1); + Point q12 = p1.lerp (t1, p2); + Point q23 = p2.lerp (t1, p3); + Point q012 = q01.lerp (t1, q12); + Point q123 = q12.lerp (t1, q23); + Point q0123 = q012.lerp (t1, q123); + + return Bezier (p0123, + p0123 + (p123 - p0123) * ((t1 - t0) / (1 - t0)), + q0123 + (q012 - q0123) * ((t1 - t0) / t1), + q0123); +} + +} /* namespace Geometry */ +} /* namespace GLyphy */ + +#endif /* GLYPHY_GEOMETRY_HH */ diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy.h 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy.h 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,354 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju + */ + +#ifndef GLYPHY_H +#define GLYPHY_H + + +#ifdef __cplusplus +extern "C" { +#endif + + +#define GLYPHY_PASTE_ARGS(prefix, name) prefix ## name +#define GLYPHY_PASTE(prefix, name) GLYPHY_PASTE_ARGS (prefix, name) + + + +typedef int glyphy_bool_t; + + +typedef struct { + double x; + double y; +} glyphy_point_t; + + + +/* + * Geometry extents + */ + +typedef struct { + double min_x; + double min_y; + double max_x; + double max_y; +} glyphy_extents_t; + +void +glyphy_extents_clear (glyphy_extents_t *extents); + +glyphy_bool_t +glyphy_extents_is_empty (const glyphy_extents_t *extents); + +void +glyphy_extents_add (glyphy_extents_t *extents, + const glyphy_point_t *p); + +void +glyphy_extents_extend (glyphy_extents_t *extents, + const glyphy_extents_t *other); + +glyphy_bool_t +glyphy_extents_includes (const glyphy_extents_t *extents, + const glyphy_point_t *p); + +void +glyphy_extents_scale (glyphy_extents_t *extents, + double x_scale, + double y_scale); + + + +/* + * Circular arcs + */ + + +typedef struct { + glyphy_point_t p0; + glyphy_point_t p1; + double d; +} glyphy_arc_t; + + +/* Build from a conventional arc representation */ +void +glyphy_arc_from_conventional (const glyphy_point_t *center, + double radius, + double angle0, + double angle1, + glyphy_bool_t negative, + glyphy_arc_t *arc); + +/* Convert to a conventional arc representation */ +void +glyphy_arc_to_conventional (glyphy_arc_t arc, + glyphy_point_t *center /* may be NULL */, + double *radius /* may be NULL */, + double *angle0 /* may be NULL */, + double *angle1 /* may be NULL */, + glyphy_bool_t *negative /* may be NULL */); + +glyphy_bool_t +glyphy_arc_is_a_line (glyphy_arc_t arc); + +void +glyphy_arc_extents (glyphy_arc_t arc, + glyphy_extents_t *extents); + + + +/* + * Approximate single pieces of geometry to/from one arc + */ + + +void +glyphy_arc_from_line (const glyphy_point_t *p0, + const glyphy_point_t *p1, + glyphy_arc_t *arc); + +void +glyphy_arc_from_conic (const glyphy_point_t *p0, + const glyphy_point_t *p1, + const glyphy_point_t *p2, + glyphy_arc_t *arc, + double *error); + +void +glyphy_arc_from_cubic (const glyphy_point_t *p0, + const glyphy_point_t *p1, + const glyphy_point_t *p2, + const glyphy_point_t *p3, + glyphy_arc_t *arc, + double *error); + +void +glyphy_arc_to_cubic (const glyphy_arc_t *arc, + glyphy_point_t *p0, + glyphy_point_t *p1, + glyphy_point_t *p2, + glyphy_point_t *p3, + double *error); + + + +/* + * Approximate outlines with multiple arcs + */ + + +typedef struct { + glyphy_point_t p; + double d; +} glyphy_arc_endpoint_t; + +typedef glyphy_bool_t (*glyphy_arc_endpoint_accumulator_callback_t) (glyphy_arc_endpoint_t *endpoint, + void *user_data); + + +typedef struct glyphy_arc_accumulator_t glyphy_arc_accumulator_t; + +glyphy_arc_accumulator_t * +glyphy_arc_accumulator_create (void); + +void +glyphy_arc_accumulator_destroy (glyphy_arc_accumulator_t *acc); + +glyphy_arc_accumulator_t * +glyphy_arc_accumulator_reference (glyphy_arc_accumulator_t *acc); + + +void +glyphy_arc_accumulator_reset (glyphy_arc_accumulator_t *acc); + + +/* Configure accumulator */ + +void +glyphy_arc_accumulator_set_tolerance (glyphy_arc_accumulator_t *acc, + double tolerance); + +double +glyphy_arc_accumulator_get_tolerance (glyphy_arc_accumulator_t *acc); + +void +glyphy_arc_accumulator_set_callback (glyphy_arc_accumulator_t *acc, + glyphy_arc_endpoint_accumulator_callback_t callback, + void *user_data); + +void +glyphy_arc_accumulator_get_callback (glyphy_arc_accumulator_t *acc, + glyphy_arc_endpoint_accumulator_callback_t *callback, + void **user_data); + +void +glyphy_arc_accumulator_set_d_metrics (glyphy_arc_accumulator_t *acc, + double max_d, + double d_bits); + +void +glyphy_arc_accumulator_get_d_metrics (glyphy_arc_accumulator_t *acc, + double *max_d, + double *d_bits); + + +/* Accumulation results */ + +unsigned int +glyphy_arc_accumulator_get_num_endpoints (glyphy_arc_accumulator_t *acc); + +double +glyphy_arc_accumulator_get_error (glyphy_arc_accumulator_t *acc); + +glyphy_bool_t +glyphy_arc_accumulator_successful (glyphy_arc_accumulator_t *acc); + + +/* Accumulate */ + +void +glyphy_arc_accumulator_move_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p0); + +void +glyphy_arc_accumulator_line_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p1); + +void +glyphy_arc_accumulator_conic_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p1, + const glyphy_point_t *p2); + +void +glyphy_arc_accumulator_cubic_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p1, + const glyphy_point_t *p2, + const glyphy_point_t *p3); + +void +glyphy_arc_accumulator_arc_to (glyphy_arc_accumulator_t *acc, + const glyphy_point_t *p1, + double d); + +void +glyphy_arc_accumulator_close_path (glyphy_arc_accumulator_t *acc); + +void +glyphy_arc_list_extents (const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + glyphy_extents_t *extents); + + + +/* + * Modify outlines for proper consumption + */ + +void +glyphy_outline_reverse (glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints); + +/* Returns true if outline was modified */ +glyphy_bool_t +glyphy_outline_winding_from_even_odd (glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + glyphy_bool_t inverse); + + + +/* + * Encode an arc outline into binary blob for fast SDF calculation + */ + + +typedef struct { + unsigned char r; + unsigned char g; + unsigned char b; + unsigned char a; +} glyphy_rgba_t; + + +/* TODO make this callback-based also? */ +/* TODO rename to glyphy_blob_encode? */ +glyphy_bool_t +glyphy_arc_list_encode_blob (const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + glyphy_rgba_t *blob, + unsigned int blob_size, + double faraway, + double avg_fetch_desired, + double *avg_fetch_achieved, + unsigned int *output_len, + unsigned int *nominal_width, /* 6bit */ + unsigned int *nominal_height, /* 6bit */ + glyphy_extents_t *extents); + +/* TBD _decode_blob */ + + + +/* + * Calculate signed-distance-field from (encoded) arc list + */ + + +double +glyphy_sdf_from_arc_list (const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + const glyphy_point_t *p, + glyphy_point_t *closest_p /* may be NULL; TBD not implemented yet */); + +/* TBD */ +double +glyphy_sdf_from_blob (const glyphy_rgba_t *blob, + unsigned int nominal_width, + unsigned int nominal_height, + const glyphy_point_t *p, + glyphy_point_t *closest_p /* may be NULL; TBD not implemented yet */); + + + +/* + * Shader source code + */ + + +/* TODO make this enum-based? */ + +const char * +glyphy_common_shader_source (void); + +const char * +glyphy_common_shader_source_path (void); + +const char * +glyphy_sdf_shader_source (void); + +const char * +glyphy_sdf_shader_source_path (void); + + +#ifdef __cplusplus +} +#endif + +#endif /* GLYPHY_H */ diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-outline.cc avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-outline.cc --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-outline.cc 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-outline.cc 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,368 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "glyphy-common.hh" +#include "glyphy-geometry.hh" + +using namespace GLyphy::Geometry; + + +void +glyphy_outline_reverse (glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints) +{ + if (!num_endpoints) + return; + + // Shift the d's first + double d0 = endpoints[0].d; + for (unsigned int i = 0; i < num_endpoints - 1; i++) + endpoints[i].d = endpoints[i + 1].d == GLYPHY_INFINITY ? GLYPHY_INFINITY : -endpoints[i + 1].d; + endpoints[num_endpoints - 1].d = d0; + + // Reverse + for (unsigned int i = 0, j = num_endpoints - 1; i < j; i++, j--) { + glyphy_arc_endpoint_t t = endpoints[i]; + endpoints[i] = endpoints[j]; + endpoints[j] = t; + } +} + + +static bool +winding (const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints) +{ + /* + * Algorithm: + * + * - Find the lowest-x part of the contour, + * - If the point is an endpoint: + * o compare the angle of the incoming and outgoing edges of that point + * to find out whether it's CW or CCW, + * - Otherwise, compare the y of the two endpoints of the arc with lowest-x point. + * + * Note: + * + * We can use a simpler algorithm here: Act as if arcs are lines, then use the + * triangle method to calculate the signed area of the contour and get the sign. + * It should work for all cases we care about. The only case failing would be + * that of two endpoints and two arcs. But we can even special-case that. + */ + + unsigned int corner = 1; + for (unsigned int i = 2; i < num_endpoints; i++) + if (endpoints[i].p.x < endpoints[corner].p.x || + (endpoints[i].p.x == endpoints[corner].p.x && + endpoints[i].p.y < endpoints[corner].p.y)) + corner = i; + + double min_x = endpoints[corner].p.x; + int winner = -1; + Point p0 (0, 0); + for (unsigned int i = 0; i < num_endpoints; i++) { + const glyphy_arc_endpoint_t &endpoint = endpoints[i]; + if (endpoint.d == GLYPHY_INFINITY || endpoint.d == 0 /* arcs only, not lines */) { + p0 = endpoint.p; + continue; + } + Arc arc (p0, endpoint.p, endpoint.d); + p0 = endpoint.p; + + Point c = arc.center (); + double r = arc.radius (); + if (c.x - r < min_x && arc.wedge_contains_point (c - Vector (r, 0))) { + min_x = c.x - r; + winner = i; + } + } + + if (winner == -1) + { + // Corner is lowest-x. Find the tangents of the two arcs connected to the + // corner and compare the tangent angles to get contour direction. + const glyphy_arc_endpoint_t ethis = endpoints[corner]; + const glyphy_arc_endpoint_t eprev = endpoints[corner - 1]; + const glyphy_arc_endpoint_t enext = endpoints[corner < num_endpoints - 1 ? corner + 1 : 1]; + double in = (-Arc (eprev.p, ethis.p, ethis.d).tangents ().second).angle (); + double out = (+Arc (ethis.p, enext.p, enext.d).tangents ().first ).angle (); + return out > in; + } + else + { + // Easy. + return endpoints[winner].d < 0; + } + + return false; +} + + +static int +categorize (double v, double ref) +{ + return v < ref - GLYPHY_EPSILON ? -1 : v > ref + GLYPHY_EPSILON ? +1 : 0; +} + +static bool +is_zero (double v) +{ + return fabs (v) < GLYPHY_EPSILON; +} + +static bool +even_odd (const glyphy_arc_endpoint_t *c_endpoints, + unsigned int num_c_endpoints, + const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints) +{ + /* + * Algorithm: + * + * - For a point on the contour, draw a halfline in a direction + * (eg. decreasing x) to infinity, + * - Count how many times it crosses all other contours, + * - Pay special attention to points falling exactly on the halfline, + * specifically, they count as +.5 or -.5, depending the direction + * of crossing. + * + * All this counting is extremely tricky: + * + * - Floating point equality cannot be relied on here, + * - Lots of arc analysis needed, + * - Without having a point that we know falls /inside/ the contour, + * there are legitimate cases that we simply cannot handle using + * this algorithm. For example, imagine the following glyph shape: + * + * +---------+ + * | +-----+ | + * | \ / | + * | \ / | + * +----o----+ + * + * If the glyph is defined as two outlines, and when analysing the + * inner outline we happen to pick the point denoted by 'o' for + * analysis, there simply is no way to differentiate this case from + * the following case: + * + * +---------+ + * | | + * | | + * | | + * +----o----+ + * / \ + * / \ + * +-----+ + * + * However, in one, the triangle should be filled in, and in the other + * filled out. + * + * One way to work around this may be to do the analysis for all endpoints + * on the outline and take majority. But even that can fail in more + * extreme yet legitimate cases, such as this one: + * + * +--+--+ + * | / \ | + * |/ \| + * + + + * |\ /| + * | \ / | + * +--o--+ + * + * The only correct algorithm I can think of requires a point that falls + * fully inside the outline. While we can try finding such a point (not + * dissimilar to the winding algorithm), it's beyond what I'm willing to + * implement right now. + */ + + const Point p = c_endpoints[0].p; + + double count = 0; + Point p0 (0, 0); + for (unsigned int i = 0; i < num_endpoints; i++) { + const glyphy_arc_endpoint_t &endpoint = endpoints[i]; + if (endpoint.d == GLYPHY_INFINITY) { + p0 = endpoint.p; + continue; + } + Arc arc (p0, endpoint.p, endpoint.d); + p0 = endpoint.p; + + /* + * Skip our own contour + */ + if (&endpoint >= c_endpoints && &endpoint < c_endpoints + num_c_endpoints) + continue; + + /* End-point y's compared to the ref point; lt, eq, or gt */ + unsigned s0 = categorize (arc.p0.y, p.y); + unsigned s1 = categorize (arc.p1.y, p.y); + + if (is_zero (arc.d)) + { + /* Line */ + + if (!s0 || !s1) + { + /* + * Add +.5 / -.5 for each endpoint on the halfline, depending on + * crossing direction. + */ + Pair t = arc.tangents (); + if (!s0 && arc.p0.x < p.x + GLYPHY_EPSILON) + count += .5 * categorize (t.first.dy, 0); + if (!s1 && arc.p1.x < p.x + GLYPHY_EPSILON) + count += .5 * categorize (t.second.dy, 0); + continue; + } + + if (s0 == s1) + continue; // Segment fully above or below the halfline + + // Find x pos that the line segment would intersect the half-line. + double x = arc.p0.x + (arc.p1.x - arc.p0.x) * ((p.y - arc.p0.y) / (arc.p1.y - arc.p0.y)); + + if (x >= p.x - GLYPHY_EPSILON) + continue; // Does not intersect halfline + + count++; // Add one for full crossing + continue; + } + else + { + /* Arc */ + + if (!s0 || !s1) + { + /* + * Add +.5 / -.5 for each endpoint on the halfline, depending on + * crossing direction. + */ + Pair t = arc.tangents (); + + /* Arc-specific logic: + * If the tangent has dy==0, use the other endpoint's + * y value to decide which way the arc will be heading. + */ + if (is_zero (t.first.dy)) + t.first.dy = +categorize (arc.p1.y, p.y); + if (is_zero (t.second.dy)) + t.second.dy = -categorize (arc.p0.y, p.y); + + if (!s0 && arc.p0.x < p.x + GLYPHY_EPSILON) + count += .5 * categorize (t.first.dy, 0); + if (!s1 && arc.p1.x < p.x + GLYPHY_EPSILON) + count += .5 * categorize (t.second.dy, 0); + } + + Point c = arc.center (); + double r = arc.radius (); + if (c.x - r >= p.x) + continue; // No chance + /* Solve for arc crossing line with y = p.y */ + double dy = p.y - c.y; + double x2 = r * r - dy * dy; + if (x2 <= GLYPHY_EPSILON) + continue; // Negative delta, no crossing + double dx = sqrt (x2); + /* There's two candidate points on the arc with the same y as the + * ref point. */ + Point pp[2] = { Point (c.x - dx, p.y), + Point (c.x + dx, p.y) }; + +#define POINTS_EQ(a,b) (is_zero (a.x - b.x) && is_zero (a.y - b.y)) + for (unsigned int i = 0; i < ARRAY_LENGTH (pp); i++) + { + /* Make sure we don't double-count endpoints that fall on the + * halfline as we already accounted for those above */ + if (!POINTS_EQ (pp[i], arc.p0) && !POINTS_EQ (pp[i], arc.p1) && + pp[i].x < p.x - GLYPHY_EPSILON && arc.wedge_contains_point (pp[i])) + count++; // Add one for full crossing + } +#undef POINTS_EQ + } + } + + return !(int (floor (count)) & 1); +} + +static bool +process_contour (glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + const glyphy_arc_endpoint_t *all_endpoints, + unsigned int num_all_endpoints, + bool inverse) +{ + /* + * Algorithm: + * + * - Find the winding direction and even-odd number, + * - If the two disagree, reverse the contour, inplace. + */ + + if (!num_endpoints) + return false; + + if (num_endpoints < 3) { + abort (); // Don't expect this + return false; // Need at least two arcs + } + if (Point (endpoints[0].p) != Point (endpoints[num_endpoints-1].p)) { + abort (); // Don't expect this + return false; // Need a closed contour + } + + if (inverse ^ + winding (endpoints, num_endpoints) ^ + even_odd (endpoints, num_endpoints, all_endpoints, num_all_endpoints)) + { + glyphy_outline_reverse (endpoints, num_endpoints); + return true; + } + + return false; +} + +/* Returns true if outline was modified */ +glyphy_bool_t +glyphy_outline_winding_from_even_odd (glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + glyphy_bool_t inverse) +{ + /* + * Algorithm: + * + * - Process one contour at a time. + */ + + unsigned int start = 0; + bool ret = false; + for (unsigned int i = 1; i < num_endpoints; i++) { + const glyphy_arc_endpoint_t &endpoint = endpoints[i]; + if (endpoint.d == GLYPHY_INFINITY) { + ret = ret | process_contour (endpoints + start, i - start, endpoints, num_endpoints, bool (inverse)); + start = i; + } + } + ret = ret | process_contour (endpoints + start, num_endpoints - start, endpoints, num_endpoints, bool (inverse)); + return ret; +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf.cc avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf.cc --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf.cc 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf.cc 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,91 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju, Wojciech Baranowski + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "glyphy-common.hh" +#include "glyphy-geometry.hh" + +using namespace GLyphy::Geometry; + +/* + * TODO + * + * Sync this with the shader sdf + */ + +double +glyphy_sdf_from_arc_list (const glyphy_arc_endpoint_t *endpoints, + unsigned int num_endpoints, + const glyphy_point_t *p, + glyphy_point_t *closest_p /* may be NULL; TBD not implemented yet */) +{ + Point c = *p; + Point p0 (0, 0); + Arc closest_arc (p0, p0, 0); + double min_dist = GLYPHY_INFINITY; + int side = 0; + for (unsigned int i = 0; i < num_endpoints; i++) { + const glyphy_arc_endpoint_t &endpoint = endpoints[i]; + if (endpoint.d == GLYPHY_INFINITY) { + p0 = endpoint.p; + continue; + } + Arc arc (p0, endpoint.p, endpoint.d); + p0 = endpoint.p; + + if (arc.wedge_contains_point (c)) { + double sdist = arc.distance_to_point (c); /* TODO This distance has the wrong sign. Fix */ + double udist = fabs (sdist) * (1 - GLYPHY_EPSILON); + if (udist <= min_dist) { + min_dist = udist; + side = sdist >= 0 ? -1 : +1; + } + } else { + double udist = std::min ((arc.p0 - c).len (), (arc.p1 - c).len ()); + if (udist < min_dist) { + min_dist = udist; + side = 0; /* unsure */ + closest_arc = arc; + } else if (side == 0 && udist == min_dist) { + /* If this new distance is the same as the current minimum, + * compare extended distances. Take the sign from the arc + * with larger extended distance. */ + double old_ext_dist = closest_arc.extended_dist (c); + double new_ext_dist = arc.extended_dist (c); + + double ext_dist = fabs (new_ext_dist) <= fabs (old_ext_dist) ? + old_ext_dist : new_ext_dist; + + /* For emboldening and stuff: */ + // min_dist = fabs (ext_dist); + side = ext_dist >= 0 ? +1 : -1; + } + } + } + + if (side == 0) { + // Technically speaking this should not happen, but it does. So try to fix it. + double ext_dist = closest_arc.extended_dist (c); + side = ext_dist >= 0 ? +1 : -1; + } + + return side * min_dist; +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf.glsl avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf.glsl --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf.glsl 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf.glsl 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,151 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju + */ + +#ifndef GLYPHY_TEXTURE1D_FUNC +#define GLYPHY_TEXTURE1D_FUNC glyphy_texture1D_func +#endif +#ifndef GLYPHY_TEXTURE1D_EXTRA_DECLS +#define GLYPHY_TEXTURE1D_EXTRA_DECLS +#endif +#ifndef GLYPHY_TEXTURE1D_EXTRA_ARGS +#define GLYPHY_TEXTURE1D_EXTRA_ARGS +#endif + +#ifndef GLYPHY_SDF_TEXTURE1D_FUNC +#define GLYPHY_SDF_TEXTURE1D_FUNC GLYPHY_TEXTURE1D_FUNC +#endif +#ifndef GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS +#define GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS GLYPHY_TEXTURE1D_EXTRA_DECLS +#endif +#ifndef GLYPHY_SDF_TEXTURE1D_EXTRA_ARGS +#define GLYPHY_SDF_TEXTURE1D_EXTRA_ARGS GLYPHY_TEXTURE1D_EXTRA_ARGS +#endif +#ifndef GLYPHY_SDF_TEXTURE1D +#define GLYPHY_SDF_TEXTURE1D(offset) GLYPHY_RGBA(GLYPHY_SDF_TEXTURE1D_FUNC (offset GLYPHY_TEXTURE1D_EXTRA_ARGS)) +#endif + +#ifndef GLYPHY_MAX_NUM_ENDPOINTS +#define GLYPHY_MAX_NUM_ENDPOINTS 32 +#endif + +glyphy_arc_list_t +glyphy_arc_list (const vec2 p, const ivec2 nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS) +{ + int cell_offset = glyphy_arc_list_offset (p, nominal_size); + vec4 arc_list_data = GLYPHY_SDF_TEXTURE1D (cell_offset); + return glyphy_arc_list_decode (arc_list_data, nominal_size); +} + +float +glyphy_sdf (const vec2 p, const ivec2 nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS) +{ + glyphy_arc_list_t arc_list = glyphy_arc_list (p, nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_ARGS); + + /* Short-circuits */ + if (arc_list.num_endpoints == 0) { + /* far-away cell */ + return GLYPHY_INFINITY * float(arc_list.side); + } if (arc_list.num_endpoints == -1) { + /* single-line */ + float angle = arc_list.line_angle; + vec2 n = vec2 (cos (angle), sin (angle)); + return dot (p - (vec2(nominal_size) * .5), n) - arc_list.line_distance; + } + + float side = float(arc_list.side); + float min_dist = GLYPHY_INFINITY; + glyphy_arc_t closest_arc; + + glyphy_arc_endpoint_t endpoint_prev, endpoint; + endpoint_prev = glyphy_arc_endpoint_decode (GLYPHY_SDF_TEXTURE1D (arc_list.offset), nominal_size); + for (int i = 1; i < GLYPHY_MAX_NUM_ENDPOINTS; i++) + { + if (i >= arc_list.num_endpoints) { + break; + } + endpoint = glyphy_arc_endpoint_decode (GLYPHY_SDF_TEXTURE1D (arc_list.offset + i), nominal_size); + glyphy_arc_t a = glyphy_arc_t (endpoint_prev.p, endpoint.p, endpoint.d); + endpoint_prev = endpoint; + if (glyphy_isinf (a.d)) continue; + + if (glyphy_arc_wedge_contains (a, p)) + { + float sdist = glyphy_arc_wedge_signed_dist (a, p); + float udist = abs (sdist) * (1. - GLYPHY_EPSILON); + if (udist <= min_dist) { + min_dist = udist; + side = sdist <= 0. ? -1. : +1.; + } + } else { + float udist = min (distance (p, a.p0), distance (p, a.p1)); + if (udist < min_dist) { + min_dist = udist; + side = 0.; /* unsure */ + closest_arc = a; + } else if (side == 0. && udist == min_dist) { + /* If this new distance is the same as the current minimum, + * compare extended distances. Take the sign from the arc + * with larger extended distance. */ + float old_ext_dist = glyphy_arc_extended_dist (closest_arc, p); + float new_ext_dist = glyphy_arc_extended_dist (a, p); + + float ext_dist = abs (new_ext_dist) <= abs (old_ext_dist) ? + old_ext_dist : new_ext_dist; + +#ifdef GLYPHY_SDF_PSEUDO_DISTANCE + /* For emboldening and stuff: */ + min_dist = abs (ext_dist); +#endif + side = sign (ext_dist); + } + } + } + + if (side == 0.) { + // Technically speaking this should not happen, but it does. So try to fix it. + float ext_dist = glyphy_arc_extended_dist (closest_arc, p); + side = sign (ext_dist); + } + + return min_dist * side; +} + +float +glyphy_point_dist (const vec2 p, const ivec2 nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS) +{ + glyphy_arc_list_t arc_list = glyphy_arc_list (p, nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_ARGS); + + float side = float(arc_list.side); + float min_dist = GLYPHY_INFINITY; + + if (arc_list.num_endpoints == 0) + return min_dist; + + glyphy_arc_endpoint_t endpoint_prev, endpoint; + endpoint_prev = glyphy_arc_endpoint_decode (GLYPHY_SDF_TEXTURE1D (arc_list.offset), nominal_size); + for (int i = 1; i < GLYPHY_MAX_NUM_ENDPOINTS; i++) + { + if (i >= arc_list.num_endpoints) { + break; + } + endpoint = glyphy_arc_endpoint_decode (GLYPHY_SDF_TEXTURE1D (arc_list.offset + i), nominal_size); + if (glyphy_isinf (endpoint.d)) continue; + min_dist = min (min_dist, distance (p, endpoint.p)); + } + return min_dist; +} diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf-glsl.h avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf-glsl.h --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf-glsl.h 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-sdf-glsl.h 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,153 @@ +static const char *glyphy_sdf_glsl = +"/*\n" +" * Copyright 2012 Google, Inc. All Rights Reserved.\n" +" *\n" +" * Licensed under the Apache License, Version 2.0 (the \"License\");\n" +" * you may not use this file except in compliance with the License.\n" +" * You may obtain a copy of the License at\n" +" *\n" +" * http://www.apache.org/licenses/LICENSE-2.0\n" +" *\n" +" * Unless required by applicable law or agreed to in writing, software\n" +" * distributed under the License is distributed on an \"AS IS\" BASIS,\n" +" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +" * See the License for the specific language governing permissions and\n" +" * limitations under the License.\n" +" *\n" +" * Google Author(s): Behdad Esfahbod, Maysum Panju\n" +" */\n" +"\n" +"#ifndef GLYPHY_TEXTURE1D_FUNC\n" +"#define GLYPHY_TEXTURE1D_FUNC glyphy_texture1D_func\n" +"#endif\n" +"#ifndef GLYPHY_TEXTURE1D_EXTRA_DECLS\n" +"#define GLYPHY_TEXTURE1D_EXTRA_DECLS\n" +"#endif\n" +"#ifndef GLYPHY_TEXTURE1D_EXTRA_ARGS\n" +"#define GLYPHY_TEXTURE1D_EXTRA_ARGS\n" +"#endif\n" +"\n" +"#ifndef GLYPHY_SDF_TEXTURE1D_FUNC\n" +"#define GLYPHY_SDF_TEXTURE1D_FUNC GLYPHY_TEXTURE1D_FUNC\n" +"#endif\n" +"#ifndef GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS\n" +"#define GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS GLYPHY_TEXTURE1D_EXTRA_DECLS\n" +"#endif\n" +"#ifndef GLYPHY_SDF_TEXTURE1D_EXTRA_ARGS\n" +"#define GLYPHY_SDF_TEXTURE1D_EXTRA_ARGS GLYPHY_TEXTURE1D_EXTRA_ARGS\n" +"#endif\n" +"#ifndef GLYPHY_SDF_TEXTURE1D\n" +"#define GLYPHY_SDF_TEXTURE1D(offset) GLYPHY_RGBA(GLYPHY_SDF_TEXTURE1D_FUNC (offset GLYPHY_TEXTURE1D_EXTRA_ARGS))\n" +"#endif\n" +"\n" +"#ifndef GLYPHY_MAX_NUM_ENDPOINTS\n" +"#define GLYPHY_MAX_NUM_ENDPOINTS 32\n" +"#endif\n" +"\n" +"glyphy_arc_list_t\n" +"glyphy_arc_list (const vec2 p, const ivec2 nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS)\n" +"{\n" +" int cell_offset = glyphy_arc_list_offset (p, nominal_size);\n" +" vec4 arc_list_data = GLYPHY_SDF_TEXTURE1D (cell_offset);\n" +" return glyphy_arc_list_decode (arc_list_data, nominal_size);\n" +"}\n" +"\n" +"float\n" +"glyphy_sdf (const vec2 p, const ivec2 nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS)\n" +"{\n" +" glyphy_arc_list_t arc_list = glyphy_arc_list (p, nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_ARGS);\n" +"\n" +" /* Short-circuits */\n" +" if (arc_list.num_endpoints == 0) {\n" +" /* far-away cell */\n" +" return GLYPHY_INFINITY * float(arc_list.side);\n" +" } if (arc_list.num_endpoints == -1) {\n" +" /* single-line */\n" +" float angle = arc_list.line_angle;\n" +" vec2 n = vec2 (cos (angle), sin (angle));\n" +" return dot (p - (vec2(nominal_size) * .5), n) - arc_list.line_distance;\n" +" }\n" +"\n" +" float side = float(arc_list.side);\n" +" float min_dist = GLYPHY_INFINITY;\n" +" glyphy_arc_t closest_arc;\n" +"\n" +" glyphy_arc_endpoint_t endpoint_prev, endpoint;\n" +" endpoint_prev = glyphy_arc_endpoint_decode (GLYPHY_SDF_TEXTURE1D (arc_list.offset), nominal_size);\n" +" for (int i = 1; i < GLYPHY_MAX_NUM_ENDPOINTS; i++)\n" +" {\n" +" if (i >= arc_list.num_endpoints) {\n" +" break;\n" +" }\n" +" endpoint = glyphy_arc_endpoint_decode (GLYPHY_SDF_TEXTURE1D (arc_list.offset + i), nominal_size);\n" +" glyphy_arc_t a = glyphy_arc_t (endpoint_prev.p, endpoint.p, endpoint.d);\n" +" endpoint_prev = endpoint;\n" +" if (glyphy_isinf (a.d)) continue;\n" +"\n" +" if (glyphy_arc_wedge_contains (a, p))\n" +" {\n" +" float sdist = glyphy_arc_wedge_signed_dist (a, p);\n" +" float udist = abs (sdist) * (1. - GLYPHY_EPSILON);\n" +" if (udist <= min_dist) {\n" +" min_dist = udist;\n" +" side = sdist <= 0. ? -1. : +1.;\n" +" }\n" +" } else {\n" +" float udist = min (distance (p, a.p0), distance (p, a.p1));\n" +" if (udist < min_dist) {\n" +" min_dist = udist;\n" +" side = 0.; /* unsure */\n" +" closest_arc = a;\n" +" } else if (side == 0. && udist == min_dist) {\n" +" /* If this new distance is the same as the current minimum,\n" +" * compare extended distances. Take the sign from the arc\n" +" * with larger extended distance. */\n" +" float old_ext_dist = glyphy_arc_extended_dist (closest_arc, p);\n" +" float new_ext_dist = glyphy_arc_extended_dist (a, p);\n" +"\n" +" float ext_dist = abs (new_ext_dist) <= abs (old_ext_dist) ?\n" +" old_ext_dist : new_ext_dist;\n" +"\n" +"#ifdef GLYPHY_SDF_PSEUDO_DISTANCE\n" +" /* For emboldening and stuff: */\n" +" min_dist = abs (ext_dist);\n" +"#endif\n" +" side = sign (ext_dist);\n" +" }\n" +" }\n" +" }\n" +"\n" +" if (side == 0.) {\n" +" // Technically speaking this should not happen, but it does. So try to fix it.\n" +" float ext_dist = glyphy_arc_extended_dist (closest_arc, p);\n" +" side = sign (ext_dist);\n" +" }\n" +"\n" +" return min_dist * side;\n" +"}\n" +"\n" +"float\n" +"glyphy_point_dist (const vec2 p, const ivec2 nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_DECLS)\n" +"{\n" +" glyphy_arc_list_t arc_list = glyphy_arc_list (p, nominal_size GLYPHY_SDF_TEXTURE1D_EXTRA_ARGS);\n" +"\n" +" float side = float(arc_list.side);\n" +" float min_dist = GLYPHY_INFINITY;\n" +"\n" +" if (arc_list.num_endpoints == 0)\n" +" return min_dist;\n" +"\n" +" glyphy_arc_endpoint_t endpoint_prev, endpoint;\n" +" endpoint_prev = glyphy_arc_endpoint_decode (GLYPHY_SDF_TEXTURE1D (arc_list.offset), nominal_size);\n" +" for (int i = 1; i < GLYPHY_MAX_NUM_ENDPOINTS; i++)\n" +" {\n" +" if (i >= arc_list.num_endpoints) {\n" +" break;\n" +" }\n" +" endpoint = glyphy_arc_endpoint_decode (GLYPHY_SDF_TEXTURE1D (arc_list.offset + i), nominal_size);\n" +" if (glyphy_isinf (endpoint.d)) continue;\n" +" min_dist = min (min_dist, distance (p, endpoint.p));\n" +" }\n" +" return min_dist;\n" +"}\n" +; diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-shaders.cc avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-shaders.cc --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-shaders.cc 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/glyphy-shaders.cc 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Copyright 2012 Google, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Google Author(s): Behdad Esfahbod, Maysum Panju, Wojciech Baranowski + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "glyphy-common.hh" + +/* + * Shader source code + */ + +/* TODO path separator */ +#define SHADER_PATH(File) PKGDATADIR "/" File + +#include "glyphy-common-glsl.h" +#include "glyphy-sdf-glsl.h" + +const char * glyphy_common_shader_source (void) { return glyphy_common_glsl; } +const char * glyphy_sdf_shader_source (void) { return glyphy_sdf_glsl; } + +const char * glyphy_common_shader_source_path (void) { return SHADER_PATH ("glyphy-common.glsl"); } +const char * glyphy_sdf_shader_source_path (void) { return SHADER_PATH ("glyphy-sdf.glsl"); } diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/stringize avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/stringize --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/stringize 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/stringize 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,17 @@ +#!/bin/sh + +if test "$#" = 0; then + echo "Usage: $0 DECL-SPEC FILE..." + exit 1 +fi +decl="$1" +shift + +echo "$decl =" +sed ' +s/\\/\\\\/g; +s/"/\\"/g; +s/^/"/; +s/$/\\n"/; +' "$@" +echo ";" diff -Nru avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/update.make avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/update.make --- avidemux2.6-2.6.7~ppa3/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/update.make 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/avidemux_plugins/ADM_videoFilters6_openGl/glGlyphy/glyphy/update.make 2014-03-12 06:15:23.000000000 +0000 @@ -0,0 +1,15 @@ +SHADERS = \ + glyphy-common.glsl \ + glyphy-sdf.glsl \ + $(NULL) +SHADERHEADERS = $(patsubst %.glsl,%-glsl.h, $(SHADERS)) + + +%-glsl.h: %.glsl stringize + $(AM_V_GEN) ./stringize "static const char *`echo "$<" | \ + sed 's@.*/@@;s/[-.]/_/g'`" < "$<" > "$@.tmp" && \ + mv "$@.tmp" "$@" || ($(RM) "$@.tmp"; false) + + +all: $(SHADERHEADERS) + diff -Nru avidemux2.6-2.6.7~ppa3/cmake/admConfigHelper.cmake avidemux2.6-2.6.8~ppa1/cmake/admConfigHelper.cmake --- avidemux2.6-2.6.7~ppa3/cmake/admConfigHelper.cmake 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/cmake/admConfigHelper.cmake 2014-03-12 06:15:23.000000000 +0000 @@ -47,6 +47,10 @@ ENDIF (NOT ${headerFile} STREQUAL "") IF (_proceed AND NOT ${ARGV2} STREQUAL "") + # On Mac, search firts in port libs, else we might use an older lib coming from the system (e.g. iconv) + IF(APPLE) + FIND_LIBRARY(${prefix}_LIBRARY_DIR ${ARGV2} PATHS /opt/local/lib NO_DEFAULT_PATH) # needed for port stuff + ENDIF(APPLE) FIND_LIBRARY(${prefix}_LIBRARY_DIR ${ARGV2}) MARK_AS_ADVANCED(${prefix}_LIBRARY_DIR) diff -Nru avidemux2.6-2.6.7~ppa3/cmake/admPyFunc.pl avidemux2.6-2.6.8~ppa1/cmake/admPyFunc.pl --- avidemux2.6-2.6.7~ppa3/cmake/admPyFunc.pl 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/cmake/admPyFunc.pl 2014-03-12 06:15:23.000000000 +0000 @@ -53,7 +53,12 @@ { my $num=shift; my $type=shift; - print OUTPUT "$type p".$num."="; + my $extra=""; + if($type=~m/^char/) + { + $extra="*"; + } + print OUTPUT "$type $extra p".$num."="; print OUTPUT castFrom($type); print OUTPUT ";\n"; } diff -Nru avidemux2.6-2.6.7~ppa3/cmake/avidemuxVersion.cmake avidemux2.6-2.6.8~ppa1/cmake/avidemuxVersion.cmake --- avidemux2.6-2.6.7~ppa3/cmake/avidemuxVersion.cmake 2013-12-06 06:33:08.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/cmake/avidemuxVersion.cmake 2014-03-12 06:15:23.000000000 +0000 @@ -1,7 +1,7 @@ SET(RELEASE 1) SET(CPACK_PACKAGE_VERSION_MAJOR "2") SET(CPACK_PACKAGE_VERSION_MINOR "6") -SET(CPACK_PACKAGE_VERSION_PATCH "7") +SET(CPACK_PACKAGE_VERSION_PATCH "8") SET(AVIDEMUX_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") IF(NOT RELEASE) SET(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${ADM_SUBVERSION}") diff -Nru avidemux2.6-2.6.7~ppa3/debian/changelog avidemux2.6-2.6.8~ppa1/debian/changelog --- avidemux2.6-2.6.7~ppa3/debian/changelog 2014-03-11 16:15:17.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/debian/changelog 2014-03-14 19:30:46.000000000 +0000 @@ -1,3 +1,10 @@ +avidemux2.6 (2.6.8~ppa1) trusty; urgency=medium + + * New upstream release. + * Del 06-libva_saucy_32.patch(upstream) + + -- anton Fri, 14 Feb 2014 23:23:27 +0400 + avidemux2.6 (2.6.7~ppa3) trusty; urgency=medium * Add 07-execinfo_library.patch. diff -Nru avidemux2.6-2.6.7~ppa3/debian/control avidemux2.6-2.6.8~ppa1/debian/control --- avidemux2.6-2.6.7~ppa3/debian/control 2014-03-11 16:03:20.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/debian/control 2014-03-14 19:20:08.000000000 +0000 @@ -24,7 +24,7 @@ Package: avidemux2.6-jobs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, avidemux2.6-common, - libavidemux2.6-6 (= ${binary:Version}) + libavidemux2.6 (= ${binary:Version}) Description: Free video editor - Jobs Avidemux is a free video editor designed for simple cutting, filtering and encoding tasks. It supports many file types, including AVI, DVD compatible @@ -47,7 +47,7 @@ Package: avidemux2.6-qt4 Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, avidemux2.6-common, - avidemux2.6-jobs, libavidemux2.6-6 (= ${binary:Version}) + avidemux2.6-jobs, libavidemux2.6 (= ${binary:Version}) Recommends: avidemux2.6-plugins-qt4 Suggests: vdpau-va-driver | xvba-va-driver | i965-va-driver Provides: avidemux @@ -88,7 +88,7 @@ Package: avidemux2.6-cli Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, avidemux2.6-common, - libavidemux2.6-6 (= ${binary:Version}) + libavidemux2.6 (= ${binary:Version}) Recommends: avidemux2.6-plugins-cli Provides: avidemux Description: Free video editor - command line version @@ -137,7 +137,7 @@ Package: avidemux2.6-plugins-common Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, - libavidemux2.6-6 (= ${binary:Version}), libjs-jquery + libavidemux2.6 (= ${binary:Version}), libjs-jquery Conflicts: avidemux-plugins Replaces: avidemux-plugins Description: Free video editor - common files for plugins @@ -215,7 +215,7 @@ This package contains the debugging symbols for the avidemux2.6-plugins-cli package. -Package: libavidemux2.6-6 +Package: libavidemux2.6 Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Recommends: mjpegtools, twolame, lame @@ -233,7 +233,7 @@ Architecture: any Section: debug Priority: extra -Depends: libavidemux2.6-6 (= ${binary:Version}), ${misc:Depends} +Depends: libavidemux2.6 (= ${binary:Version}), ${misc:Depends} Description: Free video editor (debug) For more information, see the libavidemux2.6 package. . @@ -242,7 +242,7 @@ Package: libavidemux2.6-dev Architecture: any Section: devel -Depends: libavidemux2.6-6 (= ${binary:Version}), ${misc:Depends}, libsqlite3-dev, +Depends: libavidemux2.6 (= ${binary:Version}), ${misc:Depends}, libsqlite3-dev, libvdpau-dev, libva-dev, libxext-dev, libxv-dev, libxvba-dev Description: Free video editor - development files For more information, see the libavidemux2.6 package. diff -Nru avidemux2.6-2.6.7~ppa3/debian/libavidemux2.6-6.lintian-overrides avidemux2.6-2.6.8~ppa1/debian/libavidemux2.6-6.lintian-overrides --- avidemux2.6-2.6.7~ppa3/debian/libavidemux2.6-6.lintian-overrides 2014-03-02 17:44:24.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/debian/libavidemux2.6-6.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -: shlib-without-versioned-soname -: package-name-doesnt-match-sonames -: dev-pkg-without-shlib-symlink diff -Nru avidemux2.6-2.6.7~ppa3/debian/libavidemux2.6.lintian-overrides avidemux2.6-2.6.8~ppa1/debian/libavidemux2.6.lintian-overrides --- avidemux2.6-2.6.7~ppa3/debian/libavidemux2.6.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/debian/libavidemux2.6.lintian-overrides 2014-03-02 17:44:24.000000000 +0000 @@ -0,0 +1,3 @@ +: shlib-without-versioned-soname +: package-name-doesnt-match-sonames +: dev-pkg-without-shlib-symlink diff -Nru avidemux2.6-2.6.7~ppa3/debian/patches/06-libva_saucy_32.patch avidemux2.6-2.6.8~ppa1/debian/patches/06-libva_saucy_32.patch --- avidemux2.6-2.6.7~ppa3/debian/patches/06-libva_saucy_32.patch 2013-12-09 18:37:55.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/debian/patches/06-libva_saucy_32.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -Description: Fix libva build on 32 bits saucy -Author: Thanh Tung Nguyen -Forwarded: no -Last-Update: 2013-12-09 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/CMakeLists.txt -+++ b/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/CMakeLists.txt -@@ -8,4 +8,5 @@ - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ADM_coreLibVA/include) - TARGET_LINK_LIBRARIES(ADM_coreLibVA6 va va-x11) - TARGET_LINK_LIBRARIES(ADM_coreLibVA6 ADM_core6 ADM_coreUI6 ADM_coreImage6) -+TARGET_LINK_LIBRARIES(ADM_coreLibVA6 "c") - ADM_INSTALL_LIB(ADM_coreLibVA6) diff -Nru avidemux2.6-2.6.7~ppa3/debian/patches/series avidemux2.6-2.6.8~ppa1/debian/patches/series --- avidemux2.6-2.6.7~ppa3/debian/patches/series 2014-03-04 14:54:43.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/debian/patches/series 2014-03-14 19:30:56.000000000 +0000 @@ -3,5 +3,4 @@ 03-oss4-include-dir.patch 04-x264_encoder_plugin_name.patch 05-hardening_build.patch -06-libva_saucy_32.patch 07-execinfo_library.patch diff -Nru avidemux2.6-2.6.7~ppa3/debian/rules avidemux2.6-2.6.8~ppa1/debian/rules --- avidemux2.6-2.6.7~ppa3/debian/rules 2014-03-11 16:05:49.000000000 +0000 +++ avidemux2.6-2.6.8~ppa1/debian/rules 2014-03-14 19:20:48.000000000 +0000 @@ -40,8 +40,8 @@ dh_auto_build -Bavidemux_core/$(BUILDDIR) dh_installdirs dh_auto_install -Bavidemux_core/$(BUILDDIR) --destdir=$(CURDIR)/$(FKINSTALL) - dh_auto_install -Bavidemux_core/$(BUILDDIR) --destdir=$(CURDIR)/debian/libavidemux2.6-6 - rm -r debian/libavidemux2.6-6/usr/include + dh_auto_install -Bavidemux_core/$(BUILDDIR) --destdir=$(CURDIR)/debian/libavidemux2.6 + rm -r debian/libavidemux2.6/usr/include adm_ui: dh_auto_configure -Bavidemux/cli/$(BUILDDIR) -Davidemux/cli -- $(CONFIG) @@ -81,7 +81,7 @@ dh_link dh_compress dh_fixperms - dh_strip --package=libavidemux2.6-6 --dbg-package=libavidemux2.6-dbg + dh_strip --package=libavidemux2.6 --dbg-package=libavidemux2.6-dbg dh_strip --package=avidemux2.6-cli --dbg-package=avidemux2.6-cli-dbg dh_strip --package=avidemux2.6-qt4 --dbg-package=avidemux2.6-qt4-dbg dh_strip --package=avidemux2.6-jobs --dbg-package=avidemux2.6-jobs-dbg