Guest User

Untitled

a guest
Mar 13th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.83 KB | None | 0 0
  1. diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
  2. index fd5555834b..9bded11eb6 100644
  3. --- a/libavcodec/cfhd.c
  4. +++ b/libavcodec/cfhd.c
  5. @@ -50,8 +50,11 @@ enum CFHDParam {
  6. ChannelWidth = 104,
  7. ChannelHeight = 105,
  8. PrescaleShift = 109,
  9. + Progressive = 68,
  10. };
  11.  
  12. +
  13. +
  14. static av_cold int cfhd_init(AVCodecContext *avctx)
  15. {
  16. CFHDContext *s = avctx->priv_data;
  17. @@ -83,6 +86,7 @@ static void init_frame_defaults(CFHDContext *s)
  18. s->wavelet_depth = 3;
  19. s->pshift = 1;
  20. s->codebook = 0;
  21. + s->progressive = 0;
  22. init_plane_defaults(s);
  23. }
  24.  
  25. @@ -137,6 +141,17 @@ static inline void filter(int16_t *output, ptrdiff_t out_stride,
  26. }
  27. }
  28.  
  29. +static inline void interlaced_vertical_filter(int16_t *output, int16_t *low, int16_t *high,
  30. + int width, int linesize)
  31. +{
  32. + int i;
  33. + for (i = 0; i < width; i++) {
  34. + output[i] = (*low - *high)/2;
  35. + output[i + linesize] = (*low + *high)/2;
  36. + low++;
  37. + high++;
  38. + }
  39. +}
  40. static void horiz_filter(int16_t *output, int16_t *low, int16_t *high,
  41. int width)
  42. {
  43. @@ -277,6 +292,9 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
  44. uint16_t data = bytestream2_get_be16(&gb);
  45. if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
  46. av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 16) | data);
  47. + } else if (tag == Progressive) {
  48. + av_log(avctx, AV_LOG_DEBUG, "Progressive?%"PRIu16"\n", data);
  49. + s->progressive = data;
  50. } else if (tag == ImageWidth) {
  51. av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data);
  52. s->coded_width = data;
  53. @@ -766,36 +784,71 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
  54. }
  55.  
  56. av_log(avctx, AV_LOG_DEBUG, "Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
  57. -
  58. + if (s->progressive) {
  59. + low = s->plane[plane].subband[0];
  60. + high = s->plane[plane].subband[8];
  61. + output = s->plane[plane].l_h[6];
  62. + for (i = 0; i < lowpass_width; i++) {
  63. + vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
  64. + low++;
  65. + high++;
  66. + output++;
  67. + }
  68. +
  69. + low = s->plane[plane].subband[7];
  70. + high = s->plane[plane].subband[9];
  71. + output = s->plane[plane].l_h[7];
  72. + for (i = 0; i < lowpass_width; i++) {
  73. + vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
  74. + low++;
  75. + high++;
  76. + output++;
  77. + }
  78. +
  79. + dst = (int16_t *)pic->data[act_plane];
  80. + low = s->plane[plane].l_h[6];
  81. + high = s->plane[plane].l_h[7];
  82. + for (i = 0; i < lowpass_height * 2; i++) {
  83. + horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);
  84. + low += lowpass_width;
  85. + high += lowpass_width;
  86. + dst += pic->linesize[act_plane] / 2;
  87. + }
  88. + }
  89. + else {
  90. + // Interlaced frame needs HAAR 2,2 wavelet decomposition for Inverse vertical Transform
  91. + av_log(avctx, AV_LOG_DEBUG, "interlaced frame ? %d", pic->interlaced_frame);
  92. + pic->interlaced_frame = 1;
  93. low = s->plane[plane].subband[0];
  94. - high = s->plane[plane].subband[8];
  95. + high = s->plane[plane].subband[7];
  96. output = s->plane[plane].l_h[6];
  97. - for (i = 0; i < lowpass_width; i++) {
  98. - vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
  99. - low++;
  100. - high++;
  101. - output++;
  102. + for (i = 0; i < lowpass_height; i++) {
  103. + horiz_filter(output, low, high, lowpass_width);
  104. + low += lowpass_width;
  105. + high += lowpass_width;
  106. + output += lowpass_width * 2;
  107. }
  108.  
  109. - low = s->plane[plane].subband[7];
  110. + low = s->plane[plane].subband[8];
  111. high = s->plane[plane].subband[9];
  112. output = s->plane[plane].l_h[7];
  113. - for (i = 0; i < lowpass_width; i++) {
  114. - vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
  115. - low++;
  116. - high++;
  117. - output++;
  118. + for (i = 0; i < lowpass_height; i++) {
  119. + horiz_filter(output, low, high, lowpass_width);
  120. + low += lowpass_width;
  121. + high += lowpass_width;
  122. + output += lowpass_width * 2;
  123. }
  124. -
  125. - dst = (int16_t *)pic->data[act_plane];
  126. +//#invertverticalfilter
  127. + dst = (int16_t *)pic->data[act_plane];
  128. low = s->plane[plane].l_h[6];
  129. high = s->plane[plane].l_h[7];
  130. - for (i = 0; i < lowpass_height * 2; i++) {
  131. - horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);
  132. - low += lowpass_width;
  133. - high += lowpass_width;
  134. - dst += pic->linesize[act_plane] / 2;
  135. + for (i = 0; i < lowpass_height; i++) {
  136. + interlaced_vertical_filter(dst, low, high, lowpass_width * 2, pic->linesize[act_plane]/2);
  137. + low += lowpass_width * 2;
  138. + high += lowpass_width * 2;
  139. + dst += pic->linesize[act_plane];
  140. }
  141. + }
  142. }
  143.  
  144.  
  145. diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h
  146. index 2573e750a6..f9e1c60c3b 100644
  147. --- a/libavcodec/cfhd.h
  148. +++ b/libavcodec/cfhd.h
  149. @@ -83,7 +83,8 @@ typedef struct CFHDContext {
  150. int coded_height;
  151. int cropped_height;
  152. enum AVPixelFormat coded_format;
  153. -
  154. + int progressive;
  155. +
  156. int a_width;
  157. int a_height;
  158. int a_format;
Add Comment
Please, Sign In to add comment