Skip to content

Commit 5856125

Browse files
mss-parkkpchoi
andauthored
Support 422-12 profile (#90)
* intermediate code Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * fixed code for 400-10 profile Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * modification to support 422-12 profile Signed-off-by: Minsoo Park <mss.park@samsung.com> * fixed bug Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * modification Signed-off-by: Minsoo Park <mss.park@samsung.com> * refactor code Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * support 422 12bit logging message Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * refactoring for 12bit Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> --------- Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> Signed-off-by: Minsoo Park <mss.park@samsung.com> Signed-off-by: mss-park <76668072+mss-park@users.noreply.github.com> Co-authored-by: kp5.choi@samsung.com <kp5.choi@samsung.com>
1 parent 4ee075e commit 5856125

File tree

7 files changed

+107
-65
lines changed

7 files changed

+107
-65
lines changed

app/oapv_app_dec.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static const args_opt_t dec_args_opts[] = {
7575
},
7676
{
7777
'd', "output-depth", ARGS_VAL_TYPE_INTEGER, 0, NULL,
78-
"output bit depth (8, 10) "
78+
"output bit depth (8, 10, 12) "
7979
},
8080
{
8181
ARGS_NO_KEY, "hash", ARGS_VAL_TYPE_NONE, 0, NULL,
@@ -317,6 +317,7 @@ static void print_stat_frm(oapvd_stat_t *stat, oapv_frms_t *frms, oapvm_t mid, a
317317

318318
const char * str_csp = finfo[i].cs == OAPV_CS_YCBCR400_10LE ? "4:0:0-10"
319319
: finfo[i].cs == OAPV_CS_YCBCR422_10LE ? "4:2:2-10"
320+
: finfo[i].cs == OAPV_CS_YCBCR422_12LE ? "4:2:2-12"
320321
: finfo[i].cs == OAPV_CS_YCBCR444_10LE ? "4:4:4-10"
321322
: finfo[i].cs == OAPV_CS_YCBCR4444_10LE ? "4:4:4:4-10"
322323
: "unknown-cs";
@@ -580,7 +581,7 @@ int main(int argc, const char **argv)
580581
for(i = 0; i < ofrms.num_frms; i++) {
581582
frm = &ofrms.frm[i];
582583
if(ofrms.num_frms > 0) {
583-
if(OAPV_CS_GET_BIT_DEPTH(frm->imgb->cs) != args_var->output_depth) {
584+
if(OAPV_CS_GET_BIT_DEPTH(frm->imgb->cs) != args_var->output_depth && args_var->output_csp != 1) {
584585
if(imgb_w == NULL) {
585586
imgb_w = imgb_create(frm->imgb->w[0], frm->imgb->h[0],
586587
OAPV_CS_SET(OAPV_CS_GET_FORMAT(frm->imgb->cs), args_var->output_depth, 0));

app/oapv_app_enc.c

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ static const args_opt_t enc_args_opts[] = {
113113
},
114114
{
115115
ARGS_NO_KEY, "profile", ARGS_VAL_TYPE_STRING, 0, NULL,
116-
"profile string (422-10, 400-10)"
116+
"profile string\n"
117+
" - 422-10: YCbCr422 10bit (default)\n"
118+
" - 422-12; YCbCr422 12bit\n"
119+
" - 400-10: YCbCr400 (monochrome) 10bit\n"
120+
" Note: Color space and bit depth of input video will be converted\n"
121+
" automatically to support the given profile, if needs"
117122
},
118123
{
119124
ARGS_NO_KEY, "level", ARGS_VAL_TYPE_STRING, 0, NULL,
@@ -155,7 +160,7 @@ static const args_opt_t enc_args_opts[] = {
155160
{
156161
ARGS_NO_KEY, "bitrate", ARGS_VAL_TYPE_STRING, 0, NULL,
157162
"enable ABR rate control\n"
158-
" bitrate in terms of kilo-bits per second: Kbps(none,K,k), Mbps(M,m)\n"
163+
" bitrate in terms of kbits per second: Kbps(none,K,k), Mbps(M,m)\n"
159164
" ex) 100 = 100K = 0.1M"
160165
},
161166
{
@@ -792,22 +797,41 @@ int main(int argc, const char **argv)
792797
memset(&ifrms, 0, sizeof(oapv_frm_t));
793798
memset(&rfrms, 0, sizeof(oapv_frm_t));
794799

800+
int codec_depth = (param->profile_idc == OAPV_PROFILE_422_10 || param->profile_idc == OAPV_PROFILE_400_10) ? 10 :
801+
param->profile_idc == OAPV_PROFILE_422_12 ? 12 : 0;
802+
if (codec_depth == 0) {
803+
logerr("invalid profile\n");
804+
ret = -1;
805+
goto ERR;
806+
}
807+
795808
for(int i = 0; i < num_frames; i++) {
796-
if(args_var->input_depth == 10) {
809+
if(args_var->input_depth == codec_depth) {
797810
ifrms.frm[i].imgb = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, args_var->input_depth, 0));
798811
}
799812
else {
800-
imgb_r = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, args_var->input_depth, 0));
801-
ifrms.frm[i].imgb = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, 10, 0));
813+
if (cfmt == OAPV_CF_PLANAR2) {
814+
ifrms.frm[i].imgb = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, codec_depth, 0));
815+
}
816+
else {
817+
imgb_r = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, args_var->input_depth, 0));
818+
ifrms.frm[i].imgb = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, codec_depth, 0));
819+
}
802820
}
803821

804822
if(is_rec) {
805-
if(args_var->input_depth == 10) {
823+
if(args_var->input_depth == codec_depth) {
806824
rfrms.frm[i].imgb = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, args_var->input_depth, 0));
807825
}
808826
else {
809-
imgb_w = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, args_var->input_depth, 0));
810-
rfrms.frm[i].imgb = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, 10, 0));
827+
if (cfmt == OAPV_CF_PLANAR2) {
828+
rfrms.frm[i].imgb = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, codec_depth, 0));
829+
}
830+
else
831+
{
832+
imgb_w = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, args_var->input_depth, 0));
833+
rfrms.frm[i].imgb = imgb_create(param->w, param->h, OAPV_CS_SET(cfmt, codec_depth, 0));
834+
}
811835
}
812836
rfrms.num_frms++;
813837
}
@@ -817,7 +841,7 @@ int main(int argc, const char **argv)
817841
/* encode pictures *******************************************************/
818842
while(args_var->max_au == 0 || (au_cnt < args_var->max_au)) {
819843
for(int i = 0; i < num_frames; i++) {
820-
if(args_var->input_depth == 10) {
844+
if(args_var->input_depth == codec_depth || cfmt == OAPV_CF_PLANAR2) {
821845
imgb_i = ifrms.frm[i].imgb;
822846
}
823847
else {
@@ -830,7 +854,7 @@ int main(int argc, const char **argv)
830854
state = STATE_STOP;
831855
break;
832856
}
833-
if(args_var->input_depth != 10) {
857+
if(args_var->input_depth != codec_depth && cfmt != OAPV_CF_PLANAR2) {
834858
imgb_cpy(ifrms.frm[i].imgb, imgb_i);
835859
}
836860
ifrms.frm[i].group_id = 1; // FIX-ME : need to set properly in case of multi-frame
@@ -852,7 +876,7 @@ int main(int argc, const char **argv)
852876

853877
for(int fidx = 0; fidx < num_frames; fidx++) {
854878
if(is_rec) {
855-
if(args_var->input_depth != 10) {
879+
if(args_var->input_depth != codec_depth && cfmt != OAPV_CF_PLANAR2) {
856880
imgb_cpy(imgb_w, rfrms.frm[fidx].imgb);
857881
imgb_o = imgb_w;
858882
}

app/oapv_app_y4m.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ static int y4m_parse_tags(y4m_params_t *y4m, char *tags)
153153
y4m->color_format = OAPV_CF_YCBCR422;
154154
y4m->bit_depth = 10;
155155
}
156+
else if(strcmp(colorspace, "422p12") == 0) {
157+
y4m->color_format = OAPV_CF_YCBCR422;
158+
y4m->bit_depth = 12;
159+
}
156160
else if(strcmp(colorspace, "444p10") == 0) {
157161
y4m->color_format = OAPV_CF_YCBCR444;
158162
y4m->bit_depth = 10;
@@ -245,6 +249,8 @@ static int write_y4m_header(char *fname, oapv_imgb_t *imgb)
245249
strcpy(c_buf, "422");
246250
else if(bit_depth == 10)
247251
strcpy(c_buf, "422p10");
252+
else if(bit_depth == 12)
253+
strcpy(c_buf, "422p12");
248254
}
249255
else if(color_format == OAPV_CF_YCBCR444) {
250256
if(bit_depth == 8)

inc/oapv.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ extern "C" {
135135
#define OAPV_CS_YCBCR4444_10LE OAPV_CS_SET(OAPV_CF_YCBCR4444, 10, 0)
136136
#define OAPV_CS_YCBCR400_12LE OAPV_CS_SET(OAPV_CF_YCBCR400, 12, 0)
137137
#define OAPV_CS_YCBCR420_12LE OAPV_CS_SET(OAPV_CF_YCBCR420, 12, 0)
138-
#define OAPV_CS_YCBCR400_14LE OAPV_CS_SET(OAPV_CF_YCBCR400, 14, 0)
139-
#define OAPV_CS_YCBCR420_14LE OAPV_CS_SET(OAPV_CF_YCBCR420, 14, 0)
138+
#define OAPV_CS_YCBCR422_12LE OAPV_CS_SET(OAPV_CF_YCBCR422, 12, 0)
139+
#define OAPV_CS_YCBCR444_12LE OAPV_CS_SET(OAPV_CF_YCBCR444, 12, 0)
140+
#define OAPV_CS_YCBCR4444_12LE OAPV_CS_SET(OAPV_CF_YCBCR4444, 12, 0)
140141
#define OAPV_CS_P210 OAPV_CS_SET(OAPV_CF_PLANAR2, 10, 0)
141142

142143
/* max number of color channel: ex) YCbCr4444 -> 4 channels */
@@ -207,6 +208,7 @@ extern "C" {
207208
* profiles
208209
*****************************************************************************/
209210
#define OAPV_PROFILE_422_10 (33)
211+
#define OAPV_PROFILE_422_12 (44)
210212
#define OAPV_PROFILE_400_10 (99)
211213

212214
/*****************************************************************************
@@ -406,6 +408,7 @@ struct oapv_dict_str_int {
406408
static const oapv_dict_str_int_t oapv_param_opts_profile[] = {
407409
{"422-10", OAPV_PROFILE_422_10},
408410
{"400-10", OAPV_PROFILE_400_10},
411+
{"422-12", OAPV_PROFILE_422_12},
409412
{"", 0} // termination
410413
};
411414

0 commit comments

Comments
 (0)