[FFmpeg-devel] [PATCH] hqdn3d libavfilter port
Michael Niedermayer
michaelni
Sun Sep 26 05:10:46 CEST 2010
On Sat, Sep 25, 2010 at 05:09:33PM -0700, Baptiste Coudurier wrote:
> On 9/25/10 4:56 PM, Stefano Sabatini wrote:
>> On date Saturday 2010-09-25 16:46:12 -0700, Baptiste Coudurier encoded:
>>> On 9/25/10 4:30 PM, Baptiste Coudurier wrote:
>> [...]
>>> Updated for latest svn.
>>>
>>> [...]
>
> Updated.
[...]
> + * last frame */
> + for (X = 1; X < W; X++) {
> + LineAnt[X] = PixelAnt = LowPassMul(PixelAnt, Frame[X]<<16, Horizontal);
> + PixelDst = LowPassMul(FrameAnt[X]<<8, PixelAnt, Temporal);
> + FrameAnt[X] = ((PixelDst+0x1000007F)>>8);
> + FrameDest[X]= ((PixelDst+0x10007FFF)>>16);
> + }
> +
> + for (Y = 1; Y < H; Y++) {
> + unsigned int PixelAnt;
> + unsigned short* LinePrev=&FrameAnt[Y*W];
> + sLineOffs += sStride, dLineOffs += dStride;
> + /* First pixel on each line doesn't have previous pixel */
> + PixelAnt = Frame[sLineOffs]<<16;
> + LineAnt[0] = LowPassMul(LineAnt[0], PixelAnt, Vertical);
> + PixelDst = LowPassMul(LinePrev[0]<<8, LineAnt[0], Temporal);
> + LinePrev[0] = ((PixelDst+0x1000007F)>>8);
tabs, and try patcheck just to make sure i did not miss something trivial
[...]
> +static int query_formats(AVFilterContext *ctx)
> +{
> + static const enum PixelFormat pix_fmts[] = {
> + PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV411P,
the other 8bit planar yuv formats might work too
> + };
> +
> + avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
> +
> + return 0;
> +}
> +
> +static int config_input(AVFilterLink *link)
> +{
> + HQDN3DContext *hqdn3d = link->dst->priv;
> +
> + hqdn3d->Line = av_malloc(link->w * sizeof(*hqdn3d->Line));
> + if (!hqdn3d->Line)
> + return -1;
> +
> + return 0;
> +}
> +
> +static void PrecalcCoefs(int *Ct, double Dist25)
> +{
> + int i;
> + double Gamma, Simil, C;
> +
> + Gamma = log(0.25) / log(1.0 - Dist25/255.0 - 0.00001);
> +
> + for (i = -255*16; i <= 255*16; i++) {
> + Simil = 1.0 - FFABS(i) / (16*255.0);
> + C = pow(Simil, Gamma) * 65536.0 * (double)i / 16.0;
useless cast
> + Ct[16*256+i] = (C<0) ? (C-0.5) : (C+0.5);
lrintf/round/whatever
> + }
> +
> + Ct[0] = (Dist25 != 0);
> +}
> +
> +
> +static int init(AVFilterContext *ctx, const char *args, void *opaque)
> +{
> + HQDN3DContext *hqdn3d = ctx->priv;
> + double LumSpac, LumTmp, ChromSpac, ChromTmp;
> + double Param1, Param2, Param3, Param4;
> +
> + if (args) {
> + switch(sscanf(args, "%lf:%lf:%lf:%lf",
> + &Param1, &Param2, &Param3, &Param4)) {
> + case 0:
> + LumSpac = PARAM1_DEFAULT;
> + LumTmp = PARAM3_DEFAULT;
> +
> + ChromSpac = PARAM2_DEFAULT;
> + ChromTmp = LumTmp * ChromSpac / LumSpac;
> + break;
> + case 1:
> + LumSpac = Param1;
> + LumTmp = PARAM3_DEFAULT * Param1 / PARAM1_DEFAULT;
> +
> + ChromSpac = PARAM2_DEFAULT * Param1 / PARAM1_DEFAULT;
> + ChromTmp = LumTmp * ChromSpac / LumSpac;
> + break;
> + case 2:
> + LumSpac = Param1;
> + LumTmp = PARAM3_DEFAULT * Param1 / PARAM1_DEFAULT;
> +
> + ChromSpac = Param2;
> + ChromTmp = LumTmp * ChromSpac / LumSpac;
> + break;
> + case 3:
> + LumSpac = Param1;
> + LumTmp = Param3;
> +
> + ChromSpac = Param2;
> + ChromTmp = LumTmp * ChromSpac / LumSpac;
> + break;
> + case 4:
> + LumSpac = Param1;
> + LumTmp = Param3;
> +
> + ChromSpac = Param2;
> + ChromTmp = Param4;
> + break;
> + default:
> + LumSpac = PARAM1_DEFAULT;
> + LumTmp = PARAM3_DEFAULT;
> +
> + ChromSpac = PARAM2_DEFAULT;
> + ChromTmp = LumTmp * ChromSpac / LumSpac;
> + }
theres some repeated stuff that can be factored out
[...]
> +static void uninit(AVFilterContext *ctx)
> +{
> + HQDN3DContext *hqdn3d = ctx->priv;
> +
> + if (hqdn3d->Line)
> + av_freep(&hqdn3d->Line);
> + if (hqdn3d->Frame[0])
> + av_freep(&hqdn3d->Frame[0]);
> + if (hqdn3d->Frame[1])
> + av_freep(&hqdn3d->Frame[1]);
> + if (hqdn3d->Frame[2])
> + av_freep(&hqdn3d->Frame[2]);
the ifs seem unneeded
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100926/57c37410/attachment.pgp>
More information about the ffmpeg-devel
mailing list