gstdspjpegenc.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2009 Felipe Contreras
  3. *
  4. * Author: Felipe Contreras <felipe.contreras@gmail.com>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation
  9. * version 2.1 of the License.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #include "gstdspjpegenc.h"
  22. #include "plugin.h"
  23. #include "util.h"
  24. #include "dsp_bridge.h"
  25. #include "log.h"
  26. #define GST_CAT_DEFAULT gstdsp_debug
  27. static inline GstCaps *
  28. generate_src_template(void)
  29. {
  30. GstCaps *caps;
  31. GstStructure *struc;
  32. caps = gst_caps_new_empty();
  33. struc = gst_structure_new("image/jpeg",
  34. NULL);
  35. gst_caps_append_structure(caps, struc);
  36. return caps;
  37. }
  38. static void
  39. instance_init(GTypeInstance *instance,
  40. gpointer g_class)
  41. {
  42. GstDspBase *base = GST_DSP_BASE(instance);
  43. base->alg = GSTDSP_JPEGENC;
  44. du_port_free(base->ports[0]);
  45. du_port_free(base->ports[1]);
  46. base->ports[0] = du_port_new(0, 1);
  47. base->ports[1] = du_port_new(1, 1);
  48. base->use_eos_align = TRUE;
  49. }
  50. static void
  51. base_init(gpointer g_class)
  52. {
  53. GstElementClass *element_class;
  54. GstPadTemplate *template;
  55. GstElementDetails details;
  56. element_class = GST_ELEMENT_CLASS(g_class);
  57. details.longname = "DSP video encoder";
  58. details.klass = "Codec/Encoder/Image";
  59. details.description = "Encodes JPEG images with TI's DSP algorithms";
  60. details.author = "Felipe Contreras";
  61. gst_element_class_set_details(element_class, &details);
  62. template = gst_pad_template_new("src", GST_PAD_SRC,
  63. GST_PAD_ALWAYS,
  64. generate_src_template());
  65. gst_element_class_add_pad_template(element_class, template);
  66. gst_object_unref(template);
  67. }
  68. GType
  69. gst_dsp_jpegenc_get_type(void)
  70. {
  71. static GType type = 0;
  72. if (G_UNLIKELY(type == 0)) {
  73. GTypeInfo type_info = {
  74. .class_size = sizeof(GstDspJpegEncClass),
  75. .base_init = base_init,
  76. .instance_size = sizeof(GstDspJpegEnc),
  77. .instance_init = instance_init,
  78. };
  79. type = g_type_register_static(GST_DSP_VENC_TYPE, "GstDspJpegEnc", &type_info, 0);
  80. }
  81. return type;
  82. }