gstdsph263enc.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 "gstdsph263enc.h"
  11. #include "plugin.h"
  12. #include "util.h"
  13. #include "dsp_bridge.h"
  14. #include "log.h"
  15. #define GST_CAT_DEFAULT gstdsp_debug
  16. /*
  17. * H.263 supported levels
  18. * source: http://www.itu.int/rec/T-REC-H.263/ , page 208- table of levels.
  19. */
  20. static struct gstdsp_codec_level levels[] = {
  21. {10, 99, 1485, 64000 }, /* Level 10 - QCIF@15fps */
  22. {20, 396, 5940, 128000 }, /* Level 20 - CIF@15fps */
  23. {30, 396, 11880, 384000 }, /* Level 30 - CIF@30fps */
  24. {40, 396, 11880, 2048000 }, /* Level 40 - CIF@30fps */
  25. {45, 99, 1485, 128000 }, /* Level 45 - QCIF@15fps */
  26. {50, 396, 19800, 4096000 }, /* Level 50 - CIF@50fps */
  27. {60, 810, 40500, 8192000 }, /* Level 60 - 720x288@50fps */
  28. {70, 1620, 81000, 16384000 }, /* Level 70 - 4CIF@50fps */
  29. };
  30. static inline GstCaps *
  31. generate_src_template(void)
  32. {
  33. GstCaps *caps;
  34. GstStructure *struc;
  35. caps = gst_caps_new_empty();
  36. struc = gst_structure_new("video/x-h263",
  37. "variant", G_TYPE_STRING, "itu",
  38. NULL);
  39. gst_caps_append_structure(caps, struc);
  40. return caps;
  41. }
  42. static void
  43. instance_init(GTypeInstance *instance,
  44. gpointer g_class)
  45. {
  46. GstDspBase *base = GST_DSP_BASE(instance);
  47. GstDspVEnc *self = GST_DSP_VENC(instance);
  48. base->alg = GSTDSP_H263ENC;
  49. base->codec = &td_mp4venc_codec;
  50. base->use_pinned = true;
  51. self->supported_levels = levels;
  52. self->nr_supported_levels = ARRAY_SIZE(levels);
  53. }
  54. static void
  55. base_init(gpointer g_class)
  56. {
  57. GstElementClass *element_class;
  58. GstPadTemplate *template;
  59. element_class = GST_ELEMENT_CLASS(g_class);
  60. gst_element_class_set_details_simple(element_class,
  61. "DSP video encoder",
  62. "Codec/Encoder/Video",
  63. "Encodes H.263 video with TI's DSP algorithms",
  64. "Felipe Contreras");
  65. template = gst_pad_template_new("src", GST_PAD_SRC,
  66. GST_PAD_ALWAYS,
  67. generate_src_template());
  68. gst_element_class_add_pad_template(element_class, template);
  69. gst_object_unref(template);
  70. }
  71. GType
  72. gst_dsp_h263enc_get_type(void)
  73. {
  74. static GType type;
  75. if (G_UNLIKELY(type == 0)) {
  76. GTypeInfo type_info = {
  77. .class_size = sizeof(GstDspH263EncClass),
  78. .base_init = base_init,
  79. .instance_size = sizeof(GstDspH263Enc),
  80. .instance_init = instance_init,
  81. };
  82. type = g_type_register_static(GST_DSP_VENC_TYPE, "GstDspH263Enc", &type_info, 0);
  83. }
  84. return type;
  85. }