td_mp4vdec.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (C) 2009-2010 Felipe Contreras
  3. *
  4. * Author: Felipe Contreras <felipe.contreras@gmail.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 reserved;
  24. uint32_t max_width;
  25. uint32_t max_height;
  26. uint32_t color_format;
  27. uint32_t max_framerate;
  28. uint32_t max_bitrate;
  29. uint32_t endianness;
  30. uint32_t profile;
  31. int32_t max_level;
  32. uint32_t mode;
  33. int32_t preroll;
  34. uint32_t display_width;
  35. };
  36. static void create_args(GstDspBase *base, unsigned *profile_id, void **arg_data)
  37. {
  38. GstDspVDec *self = GST_DSP_VDEC(base);
  39. struct create_args args = {
  40. .size = sizeof(args) - 4,
  41. .num_streams = 2,
  42. .in_id = 0,
  43. .in_type = 0,
  44. .in_count = base->ports[0]->num_buffers,
  45. .out_id = 1,
  46. .out_type = 0,
  47. .out_count = base->ports[1]->num_buffers,
  48. .max_width = self->width,
  49. .max_height = self->height,
  50. .color_format = self->color_format == GST_MAKE_FOURCC('U', 'Y', 'V', 'Y') ? 4 : 1,
  51. .max_framerate = 1,
  52. .max_bitrate = 1,
  53. .endianness = 1,
  54. .max_level = -1,
  55. };
  56. if (base->alg == GSTDSP_H263DEC)
  57. args.profile = 8;
  58. if (self->width * self->height > 640 * 480)
  59. *profile_id = 4;
  60. else if (self->width * self->height > 352 * 288)
  61. *profile_id = 3;
  62. else if (self->width * self->height > 176 * 144)
  63. *profile_id = 2;
  64. else
  65. *profile_id = 1;
  66. *arg_data = malloc(sizeof(args));
  67. memcpy(*arg_data, &args, sizeof(args));
  68. }
  69. struct in_params {
  70. uint32_t frame_index;
  71. int32_t buf_count;
  72. uint32_t ring_io_block_size;
  73. int32_t performance_mode;
  74. };
  75. struct out_params {
  76. uint32_t frame_index;
  77. uint32_t bytes_consumed;
  78. int32_t error_code;
  79. uint32_t frame_type;
  80. uint32_t qp[(720 * 576) / 256];
  81. int32_t mb_error_buf_flag;
  82. uint8_t mb_error_buf[(720 * 576) / 256];
  83. };
  84. static void out_recv_cb(GstDspBase *base, struct td_buffer *tb)
  85. {
  86. GstDspVDec *self = GST_DSP_VDEC(base);
  87. struct out_params *param;
  88. param = tb->params->data;
  89. tb->keyframe = (param->frame_type == 0);
  90. pr_debug(self, "error: 0x%x, frame number: %u, frame type: %u",
  91. param->error_code, param->frame_index, param->frame_type);
  92. gstdsp_vdec_len_fixup(self, tb->data);
  93. }
  94. static void setup_in_params(GstDspBase *base, dmm_buffer_t *tmp)
  95. {
  96. struct in_params *in_param;
  97. in_param = tmp->data;
  98. in_param->performance_mode = 0;
  99. }
  100. static void setup_params(GstDspBase *base)
  101. {
  102. struct in_params *in_param;
  103. struct out_params *out_param;
  104. du_port_t *p;
  105. p = base->ports[0];
  106. gstdsp_port_setup_params(base, p, sizeof(*in_param), setup_in_params);
  107. p = base->ports[1];
  108. gstdsp_port_setup_params(base, p, sizeof(*out_param), NULL);
  109. p->recv_cb = out_recv_cb;
  110. }
  111. static bool handle_extra_data(GstDspBase *base, GstBuffer *buf)
  112. {
  113. if (base->alg == GSTDSP_MPEG4VDEC)
  114. base->skip_hack++;
  115. return gstdsp_send_codec_data(base, buf);
  116. }
  117. struct td_codec td_mp4vdec_codec = {
  118. .uuid = &(const struct dsp_uuid) { 0x7e4b8541, 0x47a1, 0x11d6, 0xb1, 0x56,
  119. { 0x00, 0xb0, 0xd0, 0x17, 0x67, 0x4b } },
  120. .filename = "mp4vdec_sn.dll64P",
  121. .setup_params = setup_params,
  122. .create_args = create_args,
  123. .handle_extra_data = handle_extra_data,
  124. .flush_buffer = gstdsp_base_flush_buffer,
  125. };