[FFmpeg-devel] lavc/cfhd: alpha decompanding added to rgba12 output

Submitted by Gagandeep Singh on March 21, 2018, 4:54 a.m.

Details

Message ID 20180321045433.16506-1-deepgagan231197@gmail.com
State New
Headers show

Commit Message

Gagandeep Singh March 21, 2018, 4:54 a.m.
decompanding curve or offset were required ticket #6265
---
 libavcodec/cfhd.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Gagandeep Singh March 21, 2018, 4:25 p.m.
Guys, can you analyse this patch.

On Wed, 21 Mar 2018, 10:25 Gagandeep Singh, <deepgagan231197@gmail.com>
wrote:

> decompanding curve or offset were required ticket #6265
> ---
>  libavcodec/cfhd.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index a064cd1599..480bf93566 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -94,6 +94,22 @@ static inline int dequant_and_decompand(int level, int
> quantisation)
>             FFSIGN(level) * quantisation;
>  }
>
> +static inline void process_alpha(int16_t *alpha, int width)
> +{
> +    int alphacompandDCoffset = 256;
> +    int alphacompandGain     = 9400;
> +    int i, channel;
> +    for (i = 0; i < width; i++) {
> +        channel   = alpha[i];
> +        channel  -= alphacompandDCoffset;
> +        channel <<= 3;
> +        channel  *= alphacompandGain;
> +        channel >>= 16;
> +        channel   = av_clip_uintp2(channel, 12);
> +        alpha[i]  = channel;
> +    }
> +}
> +
>  static inline void filter(int16_t *output, ptrdiff_t out_stride,
>                            int16_t *low, ptrdiff_t low_stride,
>                            int16_t *high, ptrdiff_t high_stride,
> @@ -792,6 +808,9 @@ static int cfhd_decode(AVCodecContext *avctx, void
> *data, int *got_frame,
>          high = s->plane[plane].l_h[7];
>          for (i = 0; i < lowpass_height * 2; i++) {
>              horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);
> +            if (act_plane == 3) {
> +                process_alpha(dst, lowpass_width * 2);
> +            }
>              low  += lowpass_width;
>              high += lowpass_width;
>              dst  += pic->linesize[act_plane] / 2;
> --
> 2.14.1
>
>
Paul B Mahol March 21, 2018, 4:34 p.m.
On 3/21/18, Gagandeep Singh <deepgagan231197@gmail.com> wrote:
> decompanding curve or offset were required ticket #6265
> ---
>  libavcodec/cfhd.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index a064cd1599..480bf93566 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -94,6 +94,22 @@ static inline int dequant_and_decompand(int level, int
> quantisation)
>             FFSIGN(level) * quantisation;
>  }
>
> +static inline void process_alpha(int16_t *alpha, int width)
> +{
> +    int alphacompandDCoffset = 256;
> +    int alphacompandGain     = 9400;

Those never changes so use #define for then, and make their name all caps.

> +    int i, channel;
> +    for (i = 0; i < width; i++) {
> +        channel   = alpha[i];
> +        channel  -= alphacompandDCoffset;
> +        channel <<= 3;
> +        channel  *= alphacompandGain;
> +        channel >>= 16;
> +        channel   = av_clip_uintp2(channel, 12);
> +        alpha[i]  = channel;
> +    }
> +}
> +
>  static inline void filter(int16_t *output, ptrdiff_t out_stride,
>                            int16_t *low, ptrdiff_t low_stride,
>                            int16_t *high, ptrdiff_t high_stride,
> @@ -792,6 +808,9 @@ static int cfhd_decode(AVCodecContext *avctx, void
> *data, int *got_frame,
>          high = s->plane[plane].l_h[7];
>          for (i = 0; i < lowpass_height * 2; i++) {
>              horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);
> +            if (act_plane == 3) {
> +                process_alpha(dst, lowpass_width * 2);
> +            }
>              low  += lowpass_width;
>              high += lowpass_width;
>              dst  += pic->linesize[act_plane] / 2;
> --
> 2.14.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Patch hide | download patch | download mbox

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index a064cd1599..480bf93566 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -94,6 +94,22 @@  static inline int dequant_and_decompand(int level, int quantisation)
            FFSIGN(level) * quantisation;
 }
 
+static inline void process_alpha(int16_t *alpha, int width)
+{
+    int alphacompandDCoffset = 256;
+    int alphacompandGain     = 9400;
+    int i, channel;
+    for (i = 0; i < width; i++) {
+        channel   = alpha[i];
+        channel  -= alphacompandDCoffset;
+        channel <<= 3;
+        channel  *= alphacompandGain;
+        channel >>= 16;
+        channel   = av_clip_uintp2(channel, 12);
+        alpha[i]  = channel;
+    }
+}
+
 static inline void filter(int16_t *output, ptrdiff_t out_stride,
                           int16_t *low, ptrdiff_t low_stride,
                           int16_t *high, ptrdiff_t high_stride,
@@ -792,6 +808,9 @@  static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
         high = s->plane[plane].l_h[7];
         for (i = 0; i < lowpass_height * 2; i++) {
             horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);
+            if (act_plane == 3) {
+                process_alpha(dst, lowpass_width * 2);
+            }
             low  += lowpass_width;
             high += lowpass_width;
             dst  += pic->linesize[act_plane] / 2;