『漫游』酷论坛>『影音数码技术学习交流』>[调查]Crop&Resize方案
不败的魔术师@2006-01-13 11:23
你写吧...
大虾@2006-01-13 18:07
我要是会写就不在这叫了
MeteorRain@2006-01-13 20:54
引用
最初由 大虾 发布
我要是会写就不在这叫了
源代码给我一下,我看看。
msg7086 # gmail DOT com
大虾@2006-01-14 08:29
一直是开源的,已经注释得很详细了:
http://www.dgwxx.cn/nmmbbs/viewthread.php?tid=273
因为HTML混杂在里面,所以读起来可能有些困难。
如果有问题请加我的MSN:dgwxx # hotmail DOT com
sswroom倒是帮我写过一个VB的版本,但是有些毛病……所以就没有放出来
MeteorRain@2006-01-14 11:24
关于你的php代码,给你些建议:
1、有些地方输出的时候,像
echo "横共切:" . $k . ",纵共切:" . $l . ",AE:" . $cc . "
";
可以改用printf()来做,会比较美观可读。
2、function isodd($num)
这个函数太失败啦……
只要 $num % 2 == 1 就是奇数, $num %2 == 0 就是偶数啦……
那个我优化一下给你看看。另外,我试试看用purebasic和c++改写一下
MeteorRain@2006-01-14 19:52
- #include
- #include
- #include
-
- struct solution
- {
- int hcrop, vcrop;
- double ae, absae;
- };
- solution * sol[625];
- int recount = 0;
-
- void usort()
- {
- int i, j;
- solution * temp1;
- for(i = 0; i < recount - 1; i++)
- for(j = 0; j < recount - i - 1; j++)
- if(sol[j]->absae > sol[j+1]->absae)
- {
- temp1 = sol[j];
- sol[j] = sol[j+1];
- sol[j+1] = temp1;
- }
- }
-
- void freeall()
- {
- int i;
- for(i = 0; i < recount; i++)
- free(sol[recount]);
- recount = 0;
- }
-
- int main()
- {
- int mode, ar, hrev, vrev, hcrop, vcrop, srange, output, c=720, d, k, l, i;
- double maxae, factor2, aa, bb, cc, dd; //Ahhh~, i hate these variable names!!!
- char filename[200];
- FILE * fp;
- puts(" Crop & Resize Calculator @ C++");
- puts(" by MR, v 0.1\n");
- printf("制式\t\t1 - NTSC\t2 - PAL:");
- scanf("%d", &mode);
- printf("屏幕比例\t1 - 16:9\t2 - 4:3:");
- scanf("%d", &ar);
- printf("Target 横向分辨率:");
- scanf("%d", &hrev);
- printf("Target 纵向分辨率:");
- scanf("%d", &vrev);
- printf("横向最小切边(默认0):");
- scanf("%d", &hcrop);
- printf("纵向最小切边(默认0):");
- scanf("%d", &vcrop);
- printf("切边搜寻范围(建议20以内):");
- scanf("%d", &srange);
- printf("最大可接受AE(0 - 默认1.0):");
- scanf("%lf", &maxae);
- printf("输出过滤\t1 - All\t2 - Even number crop only:");
- scanf("%d", &output);
- getchar();
- if(maxae < 1e-6)
- maxae = 1.0;
- if(srange < 0)
- srange = 10;
- if(mode == 1)
- d = 480;
- else
- d = 576;
- if(ar == 1)
- factor2 = 0.75;
- else
- factor2 = 1.0;
- bb = (double)hrev / (double)vrev;
- for(k = hcrop; k < hcrop + srange; k++)
- {
- for(l = vcrop; l < vcrop + srange; l++)
- {
- // NTSC计算公式
- if (mode == 1)
- aa = ((c - k) * 72. / 79) / ((d - l) * factor2);
- // PAL计算公式
- else
- aa = ((c - k) * 128. / 117) / ((d - l) * factor2);
- cc = aa / bb - 1;
- dd = fabs(cc);
- if(dd < maxae && (output == 1 || output == 2 && k % 2 == 0 && l % 2 == 0))
- {
- sol[recount] = (solution*)malloc(sizeof(solution));
- sol[recount] -> hcrop = k;
- sol[recount] -> vcrop = l;
- sol[recount] -> ae = cc;
- sol[recount] -> absae = dd;
- recount++;
- }
- }
- }
- usort();
- printf("Write to file(ENTER to print on screen):");
- gets(filename);
- if(filename[0] != 0)
- {
- // to file
- fp = fopen(filename, "w");
- fputs("H-Crop,V-Crop,AspectError,Abs AspectError\n", fp);
- for(i = 0; i < recount; i++)
- fprintf(fp, "%d,%d,%.8lf,%.8lf\n", sol[i]->hcrop, sol[i]->vcrop, sol[i]->ae, sol[i]->absae);
- fclose(fp);
- puts("Written to file.");
- }
- else
- {
- puts("H-Crop\tV-Crop\t Aspect Error\tAbs AspectError");
- for(i = 0; i < recount; i++)
- printf("%3d\t%3d\t%12.8lf\t%13.8lf\n", sol[i]->hcrop, sol[i]->vcrop, sol[i]->ae, sol[i]->absae);
- }
- freeall();
- printf("Press enter key to exit...");
- getchar();
- }
C++的版本,可以用Dev-CPP附带的gcc编译器编译。
雷鸣@2006-01-20 15:21
有一个AVS插件,叫AUTOCROP
Autocrop_autocrop(mode=0) 或
loadplugin("autocrop.dll")
autocrop(mode=0)
vempx@2006-01-21 09:52
Interlaced YV12 转 Progressive YV12已经有损失了.....
也不在乎什么全程YV12了,差别不是很大.
FalconIA@2006-01-22 01:56
看到不错的代码 眼睛一亮 收了 = 3=
jiangn@2006-01-23 13:12
上面那代码是纯C嘛,哪来的"++"
jiangn@2006-01-23 13:23
对不起,没看到注释是C++风格的
«12»共2页
| TOP