td_hdmp4vdec.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (C) 2010 Nokia Corporation
  3. *
  4. * This file may be used under the terms of the GNU Lesser General Public
  5. * License version 2.1, a copy of which is found in LICENSE included in the
  6. * packaging of this file.
  7. */
  8. #include "dsp_bridge.h"
  9. #include "dmm_buffer.h"
  10. #include "gstdspbase.h"
  11. #include "gstdspvdec.h"
  12. #include "td_hdcodec.h"
  13. struct create_args {
  14. uint32_t size;
  15. uint16_t num_streams;
  16. uint16_t in_id;
  17. uint16_t in_type;
  18. uint16_t in_count;
  19. uint16_t out_id;
  20. uint16_t out_type;
  21. uint16_t out_count;
  22. uint16_t reserved;
  23. uint32_t max_width;
  24. uint32_t max_height;
  25. uint32_t color_format;
  26. uint32_t max_framerate;
  27. uint32_t max_bitrate;
  28. uint32_t endianness;
  29. uint32_t profile;
  30. int32_t max_level;
  31. uint32_t mode;
  32. int32_t preroll;
  33. uint32_t display_width;
  34. uint32_t is_h263;
  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 = 4,
  51. .max_bitrate = -1,
  52. .endianness = 1,
  53. .max_level = 8,
  54. };
  55. args.color_format = self->color_format == GST_MAKE_FOURCC('U', 'Y', 'V', 'Y') ? 4 : 1;
  56. args.is_h263 = (self->profile == 1) ? 1 : 0;
  57. *profile_id = 4;
  58. *arg_data = malloc(sizeof(args));
  59. memcpy(*arg_data, &args, sizeof(args));
  60. }
  61. struct in_params {
  62. int32_t frame_index;
  63. uint32_t usr_arg;
  64. };
  65. struct out_params {
  66. uint32_t display_id;
  67. uint32_t bytes_consumed;
  68. int32_t error_code;
  69. uint32_t frame_type;
  70. uint32_t usr_arg;
  71. int32_t ext_error_code;
  72. int32_t skip_frame;
  73. };
  74. static void out_recv_cb(GstDspBase *base, struct td_buffer *tb)
  75. {
  76. dmm_buffer_t *b = tb->data;
  77. struct out_params *param;
  78. param = tb->params->data;
  79. if (G_LIKELY(tb->user_data)) {
  80. GstBuffer *buffer = tb->user_data;
  81. GST_BUFFER_TIMESTAMP(buffer) = base->ts_array[param->usr_arg].time;
  82. GST_BUFFER_DURATION(buffer) = base->ts_array[param->usr_arg].duration;
  83. }
  84. handle_hdcodec_error(base, param->error_code, param->ext_error_code);
  85. if (G_UNLIKELY(param->skip_frame))
  86. b->skip = TRUE;
  87. else
  88. b->skip = FALSE;
  89. tb->keyframe = (param->frame_type == 0);
  90. }
  91. static void in_send_cb(GstDspBase *base, struct td_buffer *tb)
  92. {
  93. struct in_params *param;
  94. param = tb->params->data;
  95. param->usr_arg = tb->data->ts_index;
  96. param->frame_index = g_atomic_int_exchange_and_add(&param->frame_index, 1);
  97. }
  98. static void setup_params(GstDspBase *base)
  99. {
  100. struct in_params *in_param;
  101. struct out_params *out_param;
  102. du_port_t *p;
  103. p = base->ports[0];
  104. gstdsp_port_setup_params(base, p, sizeof(*in_param), NULL);
  105. p->send_cb = in_send_cb;
  106. p = base->ports[1];
  107. gstdsp_port_setup_params(base, p, sizeof(*out_param), NULL);
  108. p->recv_cb = out_recv_cb;
  109. }
  110. struct td_codec td_hdmp4vdec_codec = {
  111. .uuid = &(const struct dsp_uuid) { 0x4343bbdb, 0xd7c2, 0x4ac8, 0xb1, 0x19,
  112. { 0xf1, 0x7a, 0x9e, 0x5a, 0x33, 0xee } },
  113. .filename = "m4vhddec_sn.dll64P",
  114. .setup_params = setup_params,
  115. .create_args = create_args,
  116. .flush_buffer = gstdsp_base_flush_buffer,
  117. .ts_mode = TS_MODE_CHECK_IN,
  118. };