<div dir="ltr">Please find original patch files attached<div><br></div><div style>Is it suitable this way?</div><div style><br></div><div style>Regards</div><div style><br></div><div style>Vianney</div><div style><br></div>
<div style><br></div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/21 Jean-Baptiste Kempf <span dir="ltr"><<a href="mailto:jb@videolan.org" target="_blank">jb@videolan.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Patch does not apply.<br>
Please mail it in a better way.<br>
<br>
On 15 Apr, Vianney Boyer wrote :<br>
<div><div class="h5">><br>
> From: Vianney BOYER <<a href="mailto:vlcvboyer@gmail.com">vlcvboyer@gmail.com</a>><br>
> Date: Mon, 15 Apr 2013 20:24:45 +0200<br>
> Subject: [PATCH 1/7] Puzzle: add dedicated bezier functions<br>
><br>
><br>
> Please find the updated patch below taking into account the<br>
> following comments:<br>
><br>
> >In that case the following code will crash, maybe you should return NULL<br>
> Sure, fixed<br>
><br>
> >This should be const.<br>
> Updated<br>
><br>
> >If you fix your point number to 7, why making it variable?<br>
> Because I'll add more shapes later (such as waves) and it will be defined by less points<br>
><br>
><br>
> Regards<br>
><br>
> ---<br>
> modules/video_filter/puzzle_bezier.c | 353<br>
> ++++++++++++++++++++++++++++++++++<br>
> modules/video_filter/puzzle_bezier.h | 43 +++++<br>
> 2 files changed, 396 insertions(+)<br>
> create mode 100644 modules/video_filter/puzzle_bezier.c<br>
> create mode 100644 modules/video_filter/puzzle_bezier.h<br>
><br>
> diff --git a/modules/video_filter/puzzle_bezier.c<br>
> b/modules/video_filter/puzzle_bezier.c<br>
> new file mode 100644<br>
> index 0000000..92cc178<br>
> --- /dev/null<br>
> +++ b/modules/video_filter/puzzle_bezier.c<br>
> @@ -0,0 +1,353 @@<br>
> +/*****************************************************************************<br>
> + * puzzle_bezier.c : Bezier curves management<br>
> + *****************************************************************************<br>
> + * Copyright (C) 2013 Vianney Boyer<br>
> + * $Id$<br>
> + *<br>
> + * Author: Vianney Boyer <vlcvboyer -at- gmail -dot- com><br>
> + *<br>
> + * This program is free software; you can redistribute it and/or modify it<br>
> + * under the terms of the GNU Lesser General Public License as published by<br>
> + * the Free Software Foundation; either version 2.1 of the License, or<br>
> + * (at your option) any later version.<br>
> + *<br>
> + * This program is distributed in the hope that it will be useful,<br>
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
> + * GNU Lesser General Public License for more details.<br>
> + *<br>
> + * You should have received a copy of the GNU Lesser General Public License<br>
> + * along with this program; if not, write to the Free Software Foundation,<br>
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br>
> + *****************************************************************************/<br>
> +<br>
> +/*****************************************************************************<br>
> + * Preamble<br>
> + *****************************************************************************/<br>
> +<br>
> +#ifdef HAVE_CONFIG_H<br>
> +# include "config.h"<br>
> +#endif<br>
> +#include <math.h><br>
> +<br>
> +#include <vlc_common.h><br>
> +#include <vlc_rand.h><br>
> +<br>
> +#include "puzzle_bezier.h"<br>
> +<br>
> +/*****************************************************************************<br>
> + * scale bezier curve in order to fit into piece sector (avoid overlapping)<br>
> + *****************************************************************************/<br>
> +point_t *puzzle_scale_curve_H(int32_t i_width, int32_t i_lines,<br>
> uint8_t i_pts_nbr, point_t *ps_pt, int32_t i_shape_size)<br>
> +{<br>
> + if (ps_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + float f_x_ratio = ((float) i_width) / (1 - (-1));<br>
> + float f_y_ratio = (((float)i_lines) / 2) / (1 - (0));<br>
> + float f_x_offset = ((float)i_width) / (1 - (-1));<br>
> + float f_y_offset = 0;<br>
> + float f_bez_x, f_bez_y;<br>
> +<br>
> + float f_current_scale = 1;<br>
> +<br>
> + uint8_t i_last_pt = (3 * (i_pts_nbr-1) + 1);<br>
> +<br>
> + point_t *ps_new_pt = malloc( sizeof( point_t ) * i_last_pt );<br>
> + if (ps_new_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + bool b_fit = true;<br>
> +<br>
> + /* check if the curve fit with available space */<br>
> + do {<br>
> + b_fit = true;<br>
> +<br>
> + for (uint8_t i_p = 0; i_p < i_last_pt; i_p++) {<br>
> + if ( i_p == 0 || i_p == 1 )<br>
> + ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio +<br>
> f_x_offset;<br>
> + else if ( i_p == i_last_pt - 2 || i_p == i_last_pt - 1 )<br>
> + ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio +<br>
> f_x_offset;<br>
> + else<br>
> + ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio *<br>
> f_current_scale + f_x_offset;<br>
> + ps_new_pt[i_p].f_y = ps_pt[i_p].f_y * f_y_ratio *<br>
> f_current_scale + f_y_offset;<br>
> + }<br>
> +<br>
> + for (float f_t = 0; f_t <= i_pts_nbr - 1; f_t += 0.1 ) {<br>
> + int8_t i_main_t = floor(f_t);<br>
> + if ( i_main_t == i_pts_nbr - 1 )<br>
> + i_main_t = i_pts_nbr - 2;<br>
> + float f_sub_t = f_t - i_main_t;<br>
> +<br>
> + f_bez_x = bezier_val(ps_new_pt,f_sub_t,i_main_t,x);<br>
> + f_bez_y = bezier_val(ps_new_pt,f_sub_t,i_main_t,y);<br>
> +<br>
> + if ( f_bez_x < ((float) i_width) / 2 ) {<br>
> + if ( abs ( f_bez_y ) > ( f_bez_x * ( 0.9 *<br>
> ((float)i_lines) / ((float)i_width) ) ) )<br>
> + b_fit = false;<br>
> + }<br>
> + else {<br>
> + if ( abs ( f_bez_y ) > ( ( ((float)i_width) -<br>
> f_bez_x ) * ( 0.9 * ((float)i_lines) / ((float)i_width) ) ) )<br>
> + b_fit = false;<br>
> + }<br>
> + }<br>
> +<br>
> + if (!b_fit)<br>
> + f_current_scale = f_current_scale * 0.9;<br>
> + }<br>
> + while ((!b_fit) && (f_current_scale>0.1));<br>
> +<br>
> + if (!b_fit) {<br>
> + free(ps_new_pt);<br>
> + return NULL;<br>
> + }<br>
> +<br>
> + /* global scale shall be applied: */<br>
> + f_current_scale = f_current_scale * (0.5 + 0.5*<br>
> (float)i_shape_size / 100);<br>
> + for (uint8_t i_p = 0; i_p < i_last_pt; i_p++) {<br>
> + if ( i_p == 0 || i_p == 1 )<br>
> + ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio + f_x_offset;<br>
> + else if ( i_p == i_last_pt - 2 || i_p == i_last_pt - 1 )<br>
> + ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio + f_x_offset;<br>
> + else<br>
> + ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio *<br>
> f_current_scale + f_x_offset;<br>
> + ps_new_pt[i_p].f_y = ps_pt[i_p].f_y * f_y_ratio *<br>
> f_current_scale + f_y_offset;<br>
> + }<br>
> +<br>
> + return ps_new_pt;<br>
> +}<br>
> +<br>
> +/*****************************************************************************<br>
> + * compute horizontal data to create scaled vertical data<br>
> + *****************************************************************************/<br>
> +point_t *puzzle_H_2_scale_curve_V(int32_t i_width, int32_t i_lines,<br>
> uint8_t i_pts_nbr, point_t *ps_pt, int32_t i_shape_size)<br>
> +{<br>
> + if (ps_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + point_t *ps_bezier_scale_H = puzzle_scale_curve_H(i_lines,<br>
> i_width, i_pts_nbr, ps_pt, i_shape_size);<br>
> + point_t *ps_pts_V = puzzle_curve_H_2_V(i_pts_nbr, ps_bezier_scale_H);<br>
> + free(ps_bezier_scale_H);<br>
> +<br>
> + return ps_pts_V;<br>
> +}<br>
> +<br>
> +/*****************************************************************************<br>
> + * compute horizontal data to create vertical data<br>
> + *****************************************************************************/<br>
> +point_t *puzzle_curve_H_2_V(uint8_t i_pts_nbr, point_t *ps_pt)<br>
> +{<br>
> + if (ps_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + point_t *ps_new_pt = malloc( sizeof( point_t ) * (3 *<br>
> (i_pts_nbr-1) + 1) );<br>
> +<br>
> + if (ps_new_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + for (uint8_t i=0; i < (3 * (i_pts_nbr-1) + 1); i++) {<br>
> + ps_new_pt[i].f_x = ps_pt[i].f_y;<br>
> + ps_new_pt[i].f_y = ps_pt[i].f_x;<br>
> + }<br>
> +<br>
> + return ps_new_pt;<br>
> +}<br>
> +<br>
> +/*****************************************************************************<br>
> + * compute horizontal data to create negative ones<br>
> + *****************************************************************************/<br>
> +point_t *puzzle_curve_H_2_negative(uint8_t i_pts_nbr, point_t *ps_pt)<br>
> +{<br>
> + if (ps_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + point_t *ps_new_pt = malloc( sizeof( point_t ) * (3 *<br>
> (i_pts_nbr-1) + 1) );<br>
> + if (ps_new_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + for (uint8_t i=0; i < (3 * (i_pts_nbr-1) + 1); i++) {<br>
> + ps_new_pt[i].f_x = ps_pt[i].f_x;<br>
> + ps_new_pt[i].f_y = -ps_pt[i].f_y;<br>
> + }<br>
> +<br>
> + return ps_new_pt;<br>
> +}<br>
> +<br>
> +/*****************************************************************************<br>
> + * compute vertical data to create negative ones<br>
> + *****************************************************************************/<br>
> +point_t *puzzle_curve_V_2_negative(uint8_t i_pts_nbr, point_t *ps_pt)<br>
> +{<br>
> + if (ps_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + point_t *ps_new_pt = malloc( sizeof( point_t ) * (3 *<br>
> (i_pts_nbr-1) + 1) );<br>
> + if (ps_new_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + for (uint8_t i=0; i < (3 * (i_pts_nbr-1) + 1); i++) {<br>
> + ps_new_pt[i].f_x = -ps_pt[i].f_x;<br>
> + ps_new_pt[i].f_y = ps_pt[i].f_y;<br>
> + }<br>
> +<br>
> + return ps_new_pt;<br>
> +}<br>
> +<br>
> +/*****************************************************************************<br>
> + * generate random bezier data<br>
> + *****************************************************************************/<br>
> +point_t *puzzle_rand_bezier(uint8_t i_pts_nbr)<br>
> +{<br>
> +#define NB_PRIM 13<br>
> +/*****************************************************************************<br>
> + * The table below contains bezier points that creates a typical<br>
> + * jigsaw puzzle piece shape. One set has been defined manually.<br>
> + * Then random modifications have been applied.<br>
> + * The best results have been selected and are included here.<br>
> + *****************************************************************************/<br>
> + const point_t ps_pt[NB_PRIM][19] = { {{ -1, 0}, {<br>
> -0.708333333333333, 0},<br>
> + { -0.375, -0.333333333333333}, {<br>
> -0.166666666666667, 0.0833333333333333}, { -0.0833333333333334,<br>
> 0.208333333333333},<br>
> + { -0.375, 0.416666666666667}, {<br>
> -0.4, 0.583333333333333}, { -0.416666666666667,<br>
> 0.833333333333333},<br>
> + { -0.25, 1}, { 0, 1}, { 0.25, 1},<br>
> + { 0.416666666666667,<br>
> 0.833333333333333}, { 0.4, 0.583333333333333}, { 0.375,<br>
> 0.416666666666667},<br>
> + { 0.0833333333333334,<br>
> 0.208333333333333}, { 0.166666666666667, 0.0833333333333333}, {<br>
> 0.375, -0.333333333333333},<br>
> + { 0.708333333333333, 0}, { 1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.708231074018077,<br>
> 0.00464090724581488},<br>
> + { -0.323236452068492,<br>
> -0.372786060362316}, { -0.116455168200171, 0.044302770499351}, {<br>
> -0.0335691043909019, 0.211488362938889},<br>
> + { -0.437927544463254,<br>
> 0.38719460194857}, { -0.465325829944998, 0.551293871552922}, {<br>
> -0.483454564038933, 0.65987409733561},<br>
> + { -0.190232837055291,<br>
> 0.93567381392124}, { 0.0642797691187335, 0.936855546259066},<br>
> {0.313367868665637, 0.938012091966671},<br>
> + {0.487146524283283,<br>
> 0.816195130161918}, {0.469545566313243, 0.564387421486367},<br>
> {0.446892478470506, 0.24030153060388},<br>
> + {0.207135456718658,<br>
> 0.246041323358689}, {0.287851875888374, 0.122157561245575},<br>
> {0.492785457693622, -0.19237501290106},<br>
> + { 0.707786879710212,<br>
> 0.000871347032899226}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.704537606957651,<br>
> 0.00470344095405053},<br>
> + { -0.435930692234854,<br>
> -0.352359270526667}, { -0.228149843936683, 0.0679948519756222}, {<br>
> -0.146863413857337, 0.232442568245956},<br>
> + { -0.400774053301818,<br>
> 0.353459760810654}, { -0.422294600163745, 0.522585095895632}, {<br>
> -0.436816721748459, 0.636711316521778},<br>
> + { -0.139151386987432,<br>
> 1.08020929564109}, { 0.110882572064929, 1.08261729027387},<br>
> {0.36153850539327, 1.08503127493587},<br>
> + {0.34588115345217,<br>
> 0.865990116291394}, {0.329903557511847, 0.612892723601664},<br>
> {0.308148644342904, 0.26827818823501},<br>
> + {0.127493141873546,<br>
> 0.13002329074962}, {0.214157995034913, 0.0010516930680228},<br>
> {0.419298604696494, -0.304231373969182},<br>
> + { 0.710915592189813,<br>
> -0.00442574861414977}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.712310641244798,<br>
> -0.00176730760415818},<br>
> + { -0.493540738434648,<br>
> -0.309260977632173}, { -0.285884861158849, 0.102814242456153}, {<br>
> -0.204387117876255, 0.264539501285563},<br>
> + { -0.420693738052021,<br>
> 0.397849004532357}, { -0.441431505287778, 0.562611714939519}, {<br>
> -0.461628378308195, 0.723076990818189},<br>
> + { -0.237390284827422,<br>
> 0.937205665156549}, { 0.012635296180645, 0.941029970697368},<br>
> {0.262998571390198, 0.94485944149288},<br>
> + {0.388416614305901,<br>
> 0.85661645417048}, {0.371248440058972, 0.611257540385605},<br>
> {0.345208629600827, 0.239109662732447},<br>
> + {0.0581354739284663,<br>
> 0.176880217503811}, {0.136998743377185, 0.0517079719473858},<br>
> {0.348267592311711, -0.283619188873049},<br>
> + { 0.708090161530147,<br>
> 0.000345266964160967}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.711243094744545,<br>
> -0.00459592941542872},<br>
> + { -0.344045254972826,<br>
> -0.249350550360079}, { -0.133712969208732, 0.170729185550043}, {<br>
> -0.0464161071620253, 0.345080177938788},<br>
> + { -0.422103631801675,<br>
> 0.334575981154338}, { -0.450380528566562, 0.498555760394576}, {<br>
> -0.467099640727027, 0.595511106801977},<br>
> + { -0.207078052226595,<br>
> 0.975846125373965}, { 0.042159574981007, 0.973462055639965},<br>
> {0.287191021206139, 0.971118219914322},<br>
> + {0.330852515542335,<br>
> 0.808592956913444}, {0.310390322812144, 0.55585802623889},<br>
> {0.283433878730578, 0.222910569628582},<br>
> + {0.164262943948071,<br>
> 0.173598366742734}, {0.251741291720702, 0.049453960261478},<br>
> {0.457341230249114, -0.24232203906962},<br>
> + { 0.708383662881845,<br>
> 0.00453591968074395}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.709563566764519,<br>
> 0.000504612933340335},<br>
> + { -0.401784990268149,<br>
> -0.401999124062464}, { -0.193592021826356, 0.0146187796927396}, {<br>
> -0.111906932669809, 0.178079970851903},<br>
> + { -0.31875772800715,<br>
> 0.350308507939804}, { -0.348317101378293, 0.519642874263023}, {<br>
> -0.364751907373417, 0.613791604139223},<br>
> + { -0.261109769059908,<br>
> 0.917602975781519}, { -0.0140971269841824, 0.920487199482641},<br>
> {0.239116574515885, 0.923443829366756},<br>
> + {0.464370661288271,<br>
> 0.826483978760365}, {0.447638420230199, 0.579781906213412},<br>
> {0.422345781938457, 0.206864359478527},<br>
> + {0.125463036793575,<br>
> 0.196073913812856}, {0.210079852894537, 0.0665488867084866},<br>
> {0.418467910269307, -0.25243580242811},<br>
> + { 0.703900021885974,<br>
> 0.00330911444674605}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.705550924110721,<br>
> 0.00312677407583926},<br>
> + { -0.415041079490389,<br>
> -0.256262603613135}, { -0.206251758814373, 0.165228519752475}, {<br>
> -0.127460686840124, 0.324287121648782},<br>
> + { -0.353486555975517,<br>
> 0.448219649272319}, { -0.374301593332884, 0.615673871700604}, {<br>
> -0.394013085772568, 0.774250221227079},<br>
> + { -0.28341474824943,<br>
> 1.03226208905838}, { -0.0332682368974526, 1.03258310507818},<br>
> {0.21500235815775, 1.03290171371209},<br>
> + {0.359673321091526,<br>
> 0.870921326239785}, {0.339932613238046, 0.624982013252291},<br>
> {0.312186121753393, 0.279302764858672},<br>
> + {0.115889225615101,<br>
> 0.23413749518865}, {0.199563649684811, 0.112671061164123},<br>
> {0.404949947429742, -0.185479078044395},<br>
> + { 0.711077310890697,<br>
> -0.00496397607736578}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.703393023950601,<br>
> 0.00477096251262726},<br>
> + { -0.397655885794691,<br>
> -0.396549402674607}, { -0.188941722741602, 0.0154382717692692}, {<br>
> -0.108388702754651, 0.174444497740687},<br>
> + { -0.373390092271521,<br>
> 0.482883861046198}, { -0.40085845720332, 0.649893787354158}, {<br>
> -0.415216707820891, 0.73719313638733},<br>
> + { -0.207371750103189,<br>
> 0.945376369116883}, { 0.0450859051405016, 0.945770549381538},<br>
> {0.295681992651987, 0.946161823046823},<br>
> + {0.436428045351514,<br>
> 0.895032817250379}, {0.416214840162102, 0.640148265397975},<br>
> {0.392784984133714, 0.344702377534045},<br>
> + {0.112552686103251,<br>
> 0.228040049100136}, {0.197835182813393, 0.100734153702732},<br>
> {0.405083123585628, -0.208636299638369},<br>
> + { 0.710532321943806,<br>
> 0.00118461271792703}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.708545258498605,<br>
> -0.00125649641636185},<br>
> + { -0.337498620726249,<br>
> -0.244893936731276}, { -0.124910631945282, 0.17201407250253}, {<br>
> -0.0378099534640198, 0.342827911406433},<br>
> + { -0.388593443990334,<br>
> 0.484174318751186}, { -0.418161094500799, 0.649198946145559}, {<br>
> -0.437373248647437, 0.756426897124284},<br>
> + { -0.189109020838902,<br>
> 0.919750563663455}, { 0.0617320119458061, 0.92141119323056},<br>
> {0.31608889374516, 0.923095098586168},<br>
> + {0.498311890876136,<br>
> 0.848907293614162}, {0.486010157001842, 0.596632149071449},<br>
> {0.461260133020122, 0.0890763897591911},<br>
> + {0.075676233826577,<br>
> 0.15314863012444}, {0.155893607369245, 0.0261168678327565},<br>
> {0.366248653274704, -0.307000149194794},<br>
> + { 0.711164480468843,<br>
> 0.00394203362859574}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.707183721193905,<br>
> 0.00108263364450203},<br>
> + { -0.483784802307194,<br>
> -0.278675576139177}, { -0.276928949597787, 0.142419327760986}, {<br>
> -0.193170452053892, 0.312925871385917},<br>
> + { -0.451215340488792,<br>
> 0.477259970702323}, { -0.47460300367851, 0.643765731024187}, {<br>
> -0.494031809431451, 0.782086864170215},<br>
> + { -0.236790915210626,<br>
> 0.959374429536679}, { 0.0132927154237516, 0.955639549881874},<br>
> {0.267150847268955, 0.951848299853113},<br>
> + {0.394360682972295,<br>
> 0.847565361471232}, {0.378470732344786, 0.601630247482969},<br>
> {0.354536849929646, 0.231195987620713},<br>
> + {0.0517827835992971,<br>
> 0.214030018332778}, {0.131796334571256, 0.0912722226051247},<br>
> {0.336621017220957, -0.222972380306016},<br>
> + { 0.703679022364791,<br>
> -0.00331356185794636}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.71248840208346,<br>
> -0.000315316402810925},<br>
> + { -0.335615004340797,<br>
> -0.24819255482402}, { -0.131187942697538, 0.164054053482729}, {<br>
> -0.0493962500017139, 0.3289947791894},<br>
> + { -0.419381248020232,<br>
> 0.390159881019368}, { -0.441651048160997, 0.558451191050566}, {<br>
> -0.455822752006908, 0.665545758156122},<br>
> + { -0.233491027161151,<br>
> 0.962685238392525}, { 0.0133445688612305, 0.95860585518251},<br>
> {0.262151404887793, 0.954493893837471},<br>
> + {0.353774477399895,<br>
> 0.909561597589476}, {0.33709535778317, 0.660905314411181},<br>
> {0.31704981166686, 0.362061544110332},<br>
> + {0.105412252277536,<br>
> 0.191206346512902}, {0.186218651070473, 0.0649153599195794},<br>
> {0.398293919310497, -0.266533575537957},<br>
> + { 0.704071013216639,<br>
> 0.00309631694609307}, {1, 0}},<br>
> +<br>
> + {{ -1, 0}, { -0.705056079463317,<br>
> 0.00448211481221729},<br>
> + { -0.436957920272407,<br>
> -0.370262236529651}, { -0.229712063674328, 0.0431705143488563}, {<br>
> -0.148227797168837, 0.205722687925072},<br>
> + { -0.393257971601542,<br>
> 0.424195267916701}, { -0.413510880163265, 0.589027317989955}, {<br>
> -0.431898814144998, 0.738680926783159},<br>
> + { -0.283603628196569,<br>
> 0.915912313032585}, { -0.0357952161759055, 0.912250885919817},<br>
> {0.219122757016883, 0.908484413381742},<br>
> + {0.443769349276008,<br>
> 0.835076661704473}, {0.426106787792343, 0.583529647320461},<br>
> {0.400589787646949, 0.220121134430258},<br>
> + {0.160593774137044,<br>
> 0.15625323679053}, {0.245514983733696, 0.0314675787386357},<br>
> {0.452432214072397, -0.272582526914925},<br>
> + { 0.707859045957901,<br>
> -0.00364987569003833}, {1, 0}},<br>
> +<br>
> + { { -1, 0}, { -0.707920686483174,<br>
> 0.00318900911649754},<br>
> + { -0.434372174464315,<br>
> -0.307446433658587}, { -0.22207624254243, 0.109425261995917}, {<br>
> -0.137453117820789, 0.275594180895755},<br>
> + { -0.340508174095858,<br>
> 0.364631782467402}, { -0.369080584284576, 0.527714098008385}, {<br>
> -0.383671882476694, 0.610996631060469},<br>
> + { -0.233753076988816,<br>
> 0.939761357928644}, { 0.0204626018463874, 0.936196353095824},<br>
> {0.268226367774715, 0.932721826949446},<br>
> + {0.500766516589953,<br>
> 0.908734435247741}, {0.488915515020803, 0.659928459184412},<br>
> {0.468202989215343, 0.225079120105809},<br>
> + {0.106186153956061,<br>
> 0.298643666003939}, {0.184680334657865, 0.170455849778656},<br>
> {0.39345790442032, -0.1704960590812},<br>
> + { 0.713223372514099,<br>
> -0.000707944210808817}, {1, 0}}<br>
> + };<br>
> +<br>
> + if (i_pts_nbr != 7)<br>
> + return NULL;<br>
> +<br>
> + /* random shape */<br>
> + uint8_t i_last_pt = (3 * (i_pts_nbr-1) + 1);<br>
> + uint8_t i_item = ((uint16_t) vlc_mrand48()) % NB_PRIM;<br>
> +<br>
> + point_t *ps_new_pt = malloc( sizeof( point_t ) * i_last_pt );<br>
> + if (ps_new_pt == NULL)<br>
> + return NULL;<br>
> +<br>
> + if ((vlc_mrand48() & 1) == 1)<br>
> + for (uint8_t i=0; i < i_last_pt; i++) {<br>
> + ps_new_pt[i].f_x = ps_pt[i_item][i].f_x;<br>
> + ps_new_pt[i].f_y = ps_pt[i_item][i].f_y;<br>
> + }<br>
> + else<br>
> + for (uint8_t i=0; i < i_last_pt; i++) {<br>
> + ps_new_pt[i].f_x = ps_pt[i_item][i_last_pt-1-i].f_x;<br>
> + ps_new_pt[i].f_y = ps_pt[i_item][i_last_pt-1-i].f_y;<br>
> + }<br>
> +<br>
> + /* random shape size */<br>
> + float f_current_scale = 0.7 + ( (float) (vlc_mrand48() % 1001 )<br>
> / 1000 )*0.3;<br>
> + for (uint8_t i_p = 0; i_p < i_last_pt; i_p++) {<br>
> + if ( i_p != 0 && i_p != 1 && i_p != i_last_pt - 2 && i_p !=<br>
> i_last_pt - 1 )<br>
> + ps_new_pt[i_p].f_x = ps_new_pt[i_p].f_x * f_current_scale;<br>
> + ps_new_pt[i_p].f_y = ps_new_pt[i_p].f_y * f_current_scale;<br>
> + }<br>
> +<br>
> + /* random shape shift */<br>
> + float f_offset = ( ( (float) (vlc_mrand48() % 1001 ) / 1000 )<br>
> - 0.5 ) * 0.2;<br>
> + for (uint8_t i=1; i < i_pts_nbr - 1; i++) {<br>
> + ps_new_pt[i*3-1].f_x += f_offset;<br>
> + ps_new_pt[i*3].f_x += f_offset;<br>
> + ps_new_pt[i*3+1].f_x += f_offset;<br>
> + }<br>
> +<br>
> + return ps_new_pt;<br>
> +}<br>
> +<br>
> diff --git a/modules/video_filter/puzzle_bezier.h<br>
> b/modules/video_filter/puzzle_bezier.h<br>
> new file mode 100644<br>
> index 0000000..1720683<br>
> --- /dev/null<br>
> +++ b/modules/video_filter/puzzle_bezier.h<br>
> @@ -0,0 +1,43 @@<br>
> +/*****************************************************************************<br>
> + * puzzle_bezier.h : Bezier curves management<br>
> + *****************************************************************************<br>
> + * Copyright (C) 2013 Vianney Boyer<br>
> + * $Id$<br>
> + *<br>
> + * Author: Vianney Boyer <vlcvboyer -at- gmail -dot- com><br>
> + *<br>
> + * This program is free software; you can redistribute it and/or modify it<br>
> + * under the terms of the GNU Lesser General Public License as published by<br>
> + * the Free Software Foundation; either version 2.1 of the License, or<br>
> + * (at your option) any later version.<br>
> + *<br>
> + * This program is distributed in the hope that it will be useful,<br>
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
> + * GNU Lesser General Public License for more details.<br>
> + *<br>
> + * You should have received a copy of the GNU Lesser General Public License<br>
> + * along with this program; if not, write to the Free Software Foundation,<br>
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br>
> + *****************************************************************************/<br>
> +<br>
> +#ifndef VLC_LIB_BEZIER_H<br>
> +#define VLC_LIB_BEZIER_H 1<br>
> +<br>
> +typedef struct {<br>
> + float f_x, f_y;<br>
> + } point_t;<br>
> +<br>
> +point_t *puzzle_scale_curve_H(int32_t i_width, int32_t i_lines,<br>
> uint8_t i_pts_nbr, point_t *ps_pt, int32_t i_shape_size);<br>
> +point_t *puzzle_H_2_scale_curve_V(int32_t i_width, int32_t i_lines,<br>
> uint8_t i_pts_nbr, point_t *ps_pt, int32_t i_shape_size);<br>
> +point_t *puzzle_curve_H_2_V(uint8_t i_pts_nbr, point_t *ps_pt);<br>
> +point_t *puzzle_curve_H_2_negative(uint8_t i_pts_nbr, point_t *ps_pt);<br>
> +point_t *puzzle_curve_V_2_negative(uint8_t i_pts_nbr, point_t *ps_pt);<br>
> +point_t *puzzle_rand_bezier(uint8_t i_pts_nbr);<br>
> +<br>
> +#define bezier_val(ps_pt,f_sub_t,i_main_t,axis) (( 1 - (f_sub_t))<br>
> * ( 1 - (f_sub_t) ) * ( 1 - (f_sub_t) ) * ps_pt[ 3 * (i_main_t)<br>
> ].f_ ## axis \<br>
> + + 3 * (f_sub_t)<br>
> * ( 1 - (f_sub_t) ) * ( 1 - (f_sub_t) ) * ps_pt[ 3 * (i_main_t) + 1<br>
> ].f_ ## axis \<br>
> + + 3 * (f_sub_t)<br>
> * (f_sub_t) * ( 1 - (f_sub_t) ) * ps_pt[ 3 * (i_main_t) + 2<br>
> ].f_ ## axis \<br>
> + + (f_sub_t) *<br>
> (f_sub_t) * (f_sub_t) * ps_pt[ 3 * (i_main_t) + 3<br>
> ].f_ ## axis )<br>
> +<br>
> +#endif<br>
> --<br>
> 1.7.9.5<br>
><br>
><br>
><br>
> Le 15/04/2013 16:48, Denis Charmet a écrit :<br>
> >Le lundi 15 avril 2013 à 02:11:55, Vianney Boyer a écrit :<br>
> >>+ if (!b_fit) {<br>
> >>+ free(ps_new_pt);<br>
> >>+ ps_new_pt = NULL;<br>
> >>+ }<br>
> >In that case the following code will crash, maybe you should return NULL<br>
> >>+<br>
> >>+ /* global scale shall be applied: */<br>
> >>+ f_current_scale = f_current_scale * (0.5 + 0.5*<br>
> >>(float)i_shape_size / 100);<br>
> >>+ for (uint8_t i_p = 0; i_p < i_last_pt; i_p++) {<br>
> >>+ if ( i_p == 0 || i_p == 1 )<br>
> >>+ ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio + f_x_offset;<br>
> >>+ else if ( i_p == i_last_pt - 2 || i_p == i_last_pt - 1 )<br>
> >>+ ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio + f_x_offset;<br>
> >>+ else<br>
> >>+ ps_new_pt[i_p].f_x = ps_pt[i_p].f_x * f_x_ratio *<br>
> >>f_current_scale + f_x_offset;<br>
> >>+ ps_new_pt[i_p].f_y = ps_pt[i_p].f_y * f_y_ratio *<br>
> >>f_current_scale + f_y_offset;<br>
> >>+ }<br>
> >>+<br>
> >>+ return ps_new_pt;<br>
> >>+}<br>
> >>+point_t *puzzle_curve_H_2_negative(uint8_t i_pts_nbr, point_t *ps_pt)<br>
> >>+{<br>
> >>+ if (ps_pt == NULL)<br>
> >>+ return NULL;<br>
> >>+<br>
> >>+ point_t *ps_new_pt = malloc( sizeof( point_t ) * (3 *<br>
> >>(i_pts_nbr-1) + 1) );<br>
> >>+ if (ps_new_pt == NULL)<br>
> >>+ return NULL;<br>
> >>+<br>
> >>+ for (uint8_t i=0; i < (3 * (i_pts_nbr-1) + 1); i++) {<br>
> >>+ ps_new_pt[i].f_x = ps_pt[i].f_x;<br>
> >>+ ps_new_pt[i].f_y = -ps_pt[i].f_y;<br>
> >>+ }<br>
> >>+<br>
> >>+ return ps_new_pt;<br>
> >>+}<br>
> >>+<br>
> >>+/*****************************************************************************<br>
> >>+ * compute vertical data to create negative ones<br>
> >>+ *****************************************************************************/<br>
> >>+point_t *puzzle_curve_V_2_negative(uint8_t i_pts_nbr, point_t *ps_pt)<br>
> >>+{<br>
> >>+ if (ps_pt == NULL)<br>
> >>+ return NULL;<br>
> >>+<br>
> >>+ point_t *ps_new_pt = malloc( sizeof( point_t ) * (3 *<br>
> >>(i_pts_nbr-1) + 1) );<br>
> >>+ if (ps_new_pt == NULL)<br>
> >>+ return NULL;<br>
> >>+<br>
> >>+ for (uint8_t i=0; i < (3 * (i_pts_nbr-1) + 1); i++) {<br>
> >>+ ps_new_pt[i].f_x = -ps_pt[i].f_x;<br>
> >>+ ps_new_pt[i].f_y = ps_pt[i].f_y;<br>
> >>+ }<br>
> >>+<br>
> >>+ return ps_new_pt;<br>
> >>+}<br>
> >>+<br>
> >>+/*****************************************************************************<br>
> >>+ * generate random bezier data<br>
> >>+ *****************************************************************************/<br>
> >>+point_t *puzzle_rand_bezier(uint8_t i_pts_nbr)<br>
> >>+{<br>
> >>+#define NB_PRIM 13<br>
> >>+/*****************************************************************************<br>
> >>+ * The table below contains bezier points that creates a typical<br>
> >>+ * jigsaw puzzle piece shape. One set has been defined manually.<br>
> >>+ * Then random modifications have been applied.<br>
> >>+ * The best results have been selected and are included here.<br>
> >>+ *****************************************************************************/<br>
> >>+ point_t ps_pt[NB_PRIM][19] = { {{ -1, 0}, {<br>
> >>-0.708333333333333, 0},<br>
> > {0.39345790442032, -0.1704960590812},<br>
> >>[...]<br>
> >>+ { 0.713223372514099,<br>
> >>-0.000707944210808817}, {1, 0}}<br>
> >>+ };<br>
> >This should be const.<br>
> >>+<br>
> >>+ if (i_pts_nbr != 7)<br>
> >>+ return NULL;<br>
> >If you fix your point number to 7, why making it variable?<br>
> ><br>
> >Regards,<br>
> ><br>
><br>
</div></div><div class="im">> _______________________________________________<br>
> vlc-devel mailing list<br>
> To unsubscribe or modify your subscription options:<br>
> <a href="http://mailman.videolan.org/listinfo/vlc-devel" target="_blank">http://mailman.videolan.org/listinfo/vlc-devel</a><br>
<br>
</div>--<br>
<div class="im">Best regards,<br>
<br>
--<br>
Jean-Baptiste Kempf<br>
</div><a href="http://www.jbkempf.com/" target="_blank">http://www.jbkempf.com/</a> - <a href="tel:%2B33%20672%20704%20734" value="+33672704734">+33 672 704 734</a><br>
Sent from my Electronic Device<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="http://mailman.videolan.org/listinfo/vlc-devel" target="_blank">http://mailman.videolan.org/listinfo/vlc-devel</a><br>
</div></div></blockquote></div><br></div>