Message ID | 20180320071346.21636-1-deepgagan231197@gmail.com |
---|---|
State | Superseded |
Headers | show |
On Tue, 20 Mar 2018, 12:44 Gagandeep Singh, <deepgagan231197@gmail.com> wrote: > alpha channel required a post processing after it's decoding > --- > libavcodec/cfhd.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c > index a064cd1599..d64acab8d4 100644 > --- a/libavcodec/cfhd.c > +++ b/libavcodec/cfhd.c > @@ -94,6 +94,19 @@ static inline int dequant_and_decompand(int level, int > quantisation) > FFSIGN(level) * quantisation; > } > > +static inline void process_alpha(int16_t *alpha, int width) > +{ > + int i, channel; > + for (i = 0; i < width; i++){ > + channel = alpha[i]; > + channel -= 16 << 4; > + channel <<= 8; > + channel -= 128; > + channel /= 223; > + 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 +805,8 @@ 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 > ticket #6265, oops forgot this >
> > ticket #6265, oops forgot this > Can you confirm this makes the png in the ticket look as expected? I was expecting the companding curve to also change for alpha. Kieran
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index a064cd1599..d64acab8d4 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -94,6 +94,19 @@ static inline int dequant_and_decompand(int level, int quantisation) FFSIGN(level) * quantisation; } +static inline void process_alpha(int16_t *alpha, int width) +{ + int i, channel; + for (i = 0; i < width; i++){ + channel = alpha[i]; + channel -= 16 << 4; + channel <<= 8; + channel -= 128; + channel /= 223; + 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 +805,8 @@ 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;