summaryrefslogtreecommitdiff
path: root/omx/gstomxh264utils.c
blob: ba292115afabe2300ad215afc43e99c92c56c8af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * Copyright (C) 2011, Hewlett-Packard Development Company, L.P.
 *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>, Collabora Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 *
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "gstomxh264utils.h"

typedef struct
{
  const gchar *profile;
  OMX_VIDEO_AVCPROFILETYPE e;
} H264ProfileMapping;

static const H264ProfileMapping h264_profiles[] = {
  {"baseline", OMX_VIDEO_AVCProfileBaseline},
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
  {"constrained-baseline",
      (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileConstrainedBaseline},
#else
  {"constrained-baseline", OMX_VIDEO_AVCProfileBaseline},
#endif
  {"main", OMX_VIDEO_AVCProfileMain},
  {"high", OMX_VIDEO_AVCProfileHigh},
  {"high-10", OMX_VIDEO_AVCProfileHigh10},
  {"high-4:2:2", OMX_VIDEO_AVCProfileHigh422},
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
  {"progressive-high",
      (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileProgressiveHigh},
  {"constrained-high",
      (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileConstrainedHigh},
  {"high-10-intra",
      (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileHigh10_Intra},
  {"high-4:2:2-intra",
      (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileHigh422_Intra},
#endif
};

OMX_VIDEO_AVCPROFILETYPE
gst_omx_h264_utils_get_profile_from_str (const gchar * profile)
{
  guint i;

  for (i = 0; i < G_N_ELEMENTS (h264_profiles); i++) {
    if (g_str_equal (profile, h264_profiles[i].profile))
      return h264_profiles[i].e;
  }

  return OMX_VIDEO_AVCProfileMax;
}

const gchar *
gst_omx_h264_utils_get_profile_from_enum (OMX_VIDEO_AVCPROFILETYPE e)
{
  guint i;

  for (i = 0; i < G_N_ELEMENTS (h264_profiles); i++) {
    if (e == h264_profiles[i].e)
      return h264_profiles[i].profile;
  }

  return NULL;
}

OMX_VIDEO_AVCLEVELTYPE
gst_omx_h264_utils_get_level_from_str (const gchar * level)
{
  if (g_str_equal (level, "1")) {
    return OMX_VIDEO_AVCLevel1;
  } else if (g_str_equal (level, "1b")) {
    return OMX_VIDEO_AVCLevel1b;
  } else if (g_str_equal (level, "1.1")) {
    return OMX_VIDEO_AVCLevel11;
  } else if (g_str_equal (level, "1.2")) {
    return OMX_VIDEO_AVCLevel12;
  } else if (g_str_equal (level, "1.3")) {
    return OMX_VIDEO_AVCLevel13;
  } else if (g_str_equal (level, "2")) {
    return OMX_VIDEO_AVCLevel2;
  } else if (g_str_equal (level, "2.1")) {
    return OMX_VIDEO_AVCLevel21;
  } else if (g_str_equal (level, "2.2")) {
    return OMX_VIDEO_AVCLevel22;
  } else if (g_str_equal (level, "3")) {
    return OMX_VIDEO_AVCLevel3;
  } else if (g_str_equal (level, "3.1")) {
    return OMX_VIDEO_AVCLevel31;
  } else if (g_str_equal (level, "3.2")) {
    return OMX_VIDEO_AVCLevel32;
  } else if (g_str_equal (level, "4")) {
    return OMX_VIDEO_AVCLevel4;
  } else if (g_str_equal (level, "4.1")) {
    return OMX_VIDEO_AVCLevel41;
  } else if (g_str_equal (level, "4.2")) {
    return OMX_VIDEO_AVCLevel42;
  } else if (g_str_equal (level, "5")) {
    return OMX_VIDEO_AVCLevel5;
  } else if (g_str_equal (level, "5.1")) {
    return OMX_VIDEO_AVCLevel51;
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
  } else if (g_str_equal (level, "5.2")) {
    return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel52;
  } else if (g_str_equal (level, "6.0")) {
    return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel60;
  } else if (g_str_equal (level, "6.1")) {
    return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel61;
  } else if (g_str_equal (level, "6.2")) {
    return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel62;
#endif
  }

  return OMX_VIDEO_AVCLevelMax;
}