Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
- index fd5555834b..9bded11eb6 100644
- --- a/libavcodec/cfhd.c
- +++ b/libavcodec/cfhd.c
- @@ -50,8 +50,11 @@ enum CFHDParam {
- ChannelWidth = 104,
- ChannelHeight = 105,
- PrescaleShift = 109,
- + Progressive = 68,
- };
- +
- +
- static av_cold int cfhd_init(AVCodecContext *avctx)
- {
- CFHDContext *s = avctx->priv_data;
- @@ -83,6 +86,7 @@ static void init_frame_defaults(CFHDContext *s)
- s->wavelet_depth = 3;
- s->pshift = 1;
- s->codebook = 0;
- + s->progressive = 0;
- init_plane_defaults(s);
- }
- @@ -137,6 +141,17 @@ static inline void filter(int16_t *output, ptrdiff_t out_stride,
- }
- }
- +static inline void interlaced_vertical_filter(int16_t *output, int16_t *low, int16_t *high,
- + int width, int linesize)
- +{
- + int i;
- + for (i = 0; i < width; i++) {
- + output[i] = (*low - *high)/2;
- + output[i + linesize] = (*low + *high)/2;
- + low++;
- + high++;
- + }
- +}
- static void horiz_filter(int16_t *output, int16_t *low, int16_t *high,
- int width)
- {
- @@ -277,6 +292,9 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
- uint16_t data = bytestream2_get_be16(&gb);
- if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
- av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 16) | data);
- + } else if (tag == Progressive) {
- + av_log(avctx, AV_LOG_DEBUG, "Progressive?%"PRIu16"\n", data);
- + s->progressive = data;
- } else if (tag == ImageWidth) {
- av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data);
- s->coded_width = data;
- @@ -766,36 +784,71 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
- }
- av_log(avctx, AV_LOG_DEBUG, "Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
- -
- + if (s->progressive) {
- + low = s->plane[plane].subband[0];
- + high = s->plane[plane].subband[8];
- + output = s->plane[plane].l_h[6];
- + for (i = 0; i < lowpass_width; i++) {
- + vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
- + low++;
- + high++;
- + output++;
- + }
- +
- + low = s->plane[plane].subband[7];
- + high = s->plane[plane].subband[9];
- + output = s->plane[plane].l_h[7];
- + for (i = 0; i < lowpass_width; i++) {
- + vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
- + low++;
- + high++;
- + output++;
- + }
- +
- + dst = (int16_t *)pic->data[act_plane];
- + low = s->plane[plane].l_h[6];
- + 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);
- + low += lowpass_width;
- + high += lowpass_width;
- + dst += pic->linesize[act_plane] / 2;
- + }
- + }
- + else {
- + // Interlaced frame needs HAAR 2,2 wavelet decomposition for Inverse vertical Transform
- + av_log(avctx, AV_LOG_DEBUG, "interlaced frame ? %d", pic->interlaced_frame);
- + pic->interlaced_frame = 1;
- low = s->plane[plane].subband[0];
- - high = s->plane[plane].subband[8];
- + high = s->plane[plane].subband[7];
- output = s->plane[plane].l_h[6];
- - for (i = 0; i < lowpass_width; i++) {
- - vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
- - low++;
- - high++;
- - output++;
- + for (i = 0; i < lowpass_height; i++) {
- + horiz_filter(output, low, high, lowpass_width);
- + low += lowpass_width;
- + high += lowpass_width;
- + output += lowpass_width * 2;
- }
- - low = s->plane[plane].subband[7];
- + low = s->plane[plane].subband[8];
- high = s->plane[plane].subband[9];
- output = s->plane[plane].l_h[7];
- - for (i = 0; i < lowpass_width; i++) {
- - vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
- - low++;
- - high++;
- - output++;
- + for (i = 0; i < lowpass_height; i++) {
- + horiz_filter(output, low, high, lowpass_width);
- + low += lowpass_width;
- + high += lowpass_width;
- + output += lowpass_width * 2;
- }
- -
- - dst = (int16_t *)pic->data[act_plane];
- +//#invertverticalfilter
- + dst = (int16_t *)pic->data[act_plane];
- low = s->plane[plane].l_h[6];
- 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);
- - low += lowpass_width;
- - high += lowpass_width;
- - dst += pic->linesize[act_plane] / 2;
- + for (i = 0; i < lowpass_height; i++) {
- + interlaced_vertical_filter(dst, low, high, lowpass_width * 2, pic->linesize[act_plane]/2);
- + low += lowpass_width * 2;
- + high += lowpass_width * 2;
- + dst += pic->linesize[act_plane];
- }
- + }
- }
- diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h
- index 2573e750a6..f9e1c60c3b 100644
- --- a/libavcodec/cfhd.h
- +++ b/libavcodec/cfhd.h
- @@ -83,7 +83,8 @@ typedef struct CFHDContext {
- int coded_height;
- int cropped_height;
- enum AVPixelFormat coded_format;
- -
- + int progressive;
- +
- int a_width;
- int a_height;
- int a_format;
Add Comment
Please, Sign In to add comment