Guest User

Untitled

a guest
Mar 12th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.70 KB | None | 0 0
  1. diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
  2. index fd5555834b..18a3e0f29e 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,69 @@ 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. low = s->plane[plane].subband[0];
  92. - high = s->plane[plane].subband[8];
  93. + high = s->plane[plane].subband[7];
  94. output = s->plane[plane].l_h[6];
  95. - for (i = 0; i < lowpass_width; i++) {
  96. - vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
  97. - low++;
  98. - high++;
  99. - output++;
  100. + for (i = 0; i < lowpass_height; i++) {
  101. + horiz_filter(output, low, high, lowpass_width);
  102. + low += lowpass_width;
  103. + high += lowpass_width;
  104. + output += lowpass_width * 2;
  105. }
  106.  
  107. - low = s->plane[plane].subband[7];
  108. + low = s->plane[plane].subband[8];
  109. high = s->plane[plane].subband[9];
  110. output = s->plane[plane].l_h[7];
  111. - for (i = 0; i < lowpass_width; i++) {
  112. - vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
  113. - low++;
  114. - high++;
  115. - output++;
  116. + for (i = 0; i < lowpass_height; i++) {
  117. + horiz_filter(output, low, high, lowpass_width);
  118. + low += lowpass_width;
  119. + high += lowpass_width;
  120. + output += lowpass_width * 2;
  121. }
  122. -
  123. - dst = (int16_t *)pic->data[act_plane];
  124. +//#invertverticalfilter
  125. + dst = (int16_t *)pic->data[act_plane];
  126. low = s->plane[plane].l_h[6];
  127. high = s->plane[plane].l_h[7];
  128. - for (i = 0; i < lowpass_height * 2; i++) {
  129. - horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);
  130. - low += lowpass_width;
  131. - high += lowpass_width;
  132. - dst += pic->linesize[act_plane] / 2;
  133. + for (i = 0; i < lowpass_height; i++) {
  134. + interlaced_vertical_filter(dst, low, high, lowpass_width * 2, pic->linesize[act_plane]/2);
  135. + low += lowpass_width * 2;
  136. + high += lowpass_width * 2;
  137. + dst += pic->linesize[act_plane];
  138. }
  139. + }
  140. }
  141.  
  142.  
  143. diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h
  144. index 2573e750a6..f9e1c60c3b 100644
  145. --- a/libavcodec/cfhd.h
  146. +++ b/libavcodec/cfhd.h
  147. @@ -83,7 +83,8 @@ typedef struct CFHDContext {
  148. int coded_height;
  149. int cropped_height;
  150. enum AVPixelFormat coded_format;
  151. -
  152. + int progressive;
  153. +
  154. int a_width;
  155. int a_height;
  156. int a_format;
Add Comment
Please, Sign In to add comment