td_jpegdec.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Copyright (C) 2010 Igalia S.L.
  3. *
  4. * Author: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
  5. *
  6. * This file may be used under the terms of the GNU Lesser General Public
  7. * License version 2.1, a copy of which is found in LICENSE included in the
  8. * packaging of this file.
  9. */
  10. #include "dsp_bridge.h"
  11. #include "dmm_buffer.h"
  12. #include "gstdspbase.h"
  13. #include "gstdspvdec.h"
  14. struct create_args {
  15. uint32_t size;
  16. uint16_t num_streams;
  17. uint16_t in_id;
  18. uint16_t in_type;
  19. uint16_t in_count;
  20. uint16_t out_id;
  21. uint16_t out_type;
  22. uint16_t out_count;
  23. uint16_t max_height;
  24. uint16_t max_width;
  25. uint16_t progressive;
  26. uint16_t color_format;
  27. uint16_t unknown;
  28. uint16_t sections_input;
  29. uint16_t sections_output;
  30. uint16_t is_argb32;
  31. };
  32. static void create_args(GstDspBase *base, unsigned *profile_id, void **arg_data)
  33. {
  34. GstDspVDec *self = GST_DSP_VDEC(base);
  35. struct create_args args = {
  36. .size = 15 * sizeof(uint16_t), /* the SN seems to be wrongly picky */
  37. .num_streams = 2,
  38. .in_id = 0,
  39. .in_type = 0,
  40. .in_count = base->ports[0]->num_buffers,
  41. .out_id = 1,
  42. .out_type = 0,
  43. .out_count = base->ports[1]->num_buffers,
  44. .max_height = self->height,
  45. .max_width = self->width,
  46. .progressive = self->jpeg_is_interlaced ? 1 : 0,
  47. .color_format = self->color_format == GST_MAKE_FOURCC('U', 'Y', 'V', 'Y') ? 4 : 1,
  48. };
  49. if (self->jpeg_is_interlaced) {
  50. if (self->width * self->height > 2560 * 2048)
  51. *profile_id = 9;
  52. else if (self->width * self->height > 2560 * 1600)
  53. *profile_id = 8;
  54. else if (self->width * self->height > 2048 * 1536)
  55. *profile_id = 7;
  56. else if (self->width * self->height > 1920 * 1200)
  57. *profile_id = 6;
  58. else if (self->width * self->height > 1280 * 1024)
  59. *profile_id = 5;
  60. else if (self->width * self->height > 800 * 600)
  61. *profile_id = 4;
  62. else if (self->width * self->height > 640 * 480)
  63. *profile_id = 3;
  64. else if (self->width * self->height > 352 * 288)
  65. *profile_id = 2;
  66. else if (self->width * self->height > 176 * 144)
  67. *profile_id = 1;
  68. else
  69. *profile_id = 0;
  70. }
  71. else
  72. *profile_id = -1;
  73. *arg_data = malloc(sizeof(args));
  74. memcpy(*arg_data, &args, sizeof(args));
  75. }
  76. struct in_params {
  77. int32_t buf_count;
  78. uint32_t frame_count;
  79. uint32_t frame_align;
  80. uint32_t frame_size;
  81. uint32_t display_width;
  82. uint32_t reserved_0;
  83. uint32_t reserved_1;
  84. uint32_t reserved_2;
  85. uint32_t reserved_3;
  86. uint32_t resize_option;
  87. uint32_t num_mcu;
  88. uint32_t decode_header;
  89. uint32_t max_height;
  90. uint32_t max_width;
  91. uint32_t max_scans;
  92. uint32_t endianness;
  93. uint32_t color_format;
  94. uint32_t rgb_format;
  95. uint32_t num_mcu_row;
  96. uint32_t x_org;
  97. uint32_t y_org;
  98. uint32_t x_lenght;
  99. uint32_t y_length;
  100. uint32_t argb;
  101. uint32_t total_size;
  102. };
  103. struct out_params {
  104. int32_t buf_count;
  105. uint32_t frame_count;
  106. uint32_t frame_align;
  107. uint32_t frame_size;
  108. uint32_t img_format;
  109. uint32_t width;
  110. uint32_t height;
  111. uint32_t progressive;
  112. uint32_t error_code;
  113. uint32_t reserved_0;
  114. uint32_t reserved_1;
  115. uint32_t reserved_2;
  116. uint32_t last_mcu;
  117. uint32_t stride[3];
  118. uint32_t output_height;
  119. uint32_t output_width;
  120. uint32_t total_au;
  121. uint32_t bytes_consumed;
  122. uint32_t current_au;
  123. uint32_t current_scan;
  124. int32_t dsp_error;
  125. };
  126. static void setup_in_params(GstDspBase *base, dmm_buffer_t *tmp)
  127. {
  128. struct in_params *in_param;
  129. GstDspVDec *self = GST_DSP_VDEC(base);
  130. in_param = tmp->data;
  131. in_param->frame_count = 1;
  132. in_param->frame_align = 4;
  133. in_param->display_width = 1600;
  134. in_param->color_format = self->color_format == GST_MAKE_FOURCC('U', 'Y', 'V', 'Y') ? 4 : 1;
  135. in_param->rgb_format = 9;
  136. }
  137. static void setup_params(GstDspBase *base)
  138. {
  139. struct in_params *in_param;
  140. struct out_params *out_param;
  141. du_port_t *p;
  142. p = base->ports[0];
  143. gstdsp_port_setup_params(base, p, sizeof(*in_param), setup_in_params);
  144. p = base->ports[1];
  145. gstdsp_port_setup_params(base, p, sizeof(*out_param), NULL);
  146. }
  147. struct td_codec td_jpegdec_codec = {
  148. .uuid = &(const struct dsp_uuid) { 0x5D9CB711, 0x4645, 0x11d6, 0xb0, 0xdc,
  149. { 0x00, 0xc0, 0x4f, 0x1f, 0xc0, 0x36 } },
  150. .filename = "jpegdec_sn.dll64P",
  151. .setup_params = setup_params,
  152. .create_args = create_args,
  153. };