@@ -1000,6 +1000,247 @@ static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
1000
1000
va_end (args );
1001
1001
}
1002
1002
1003
+ typedef struct _TracePictureLayout {
1004
+ /*input*/
1005
+ uint32_t fourcc ;
1006
+ uint32_t width ;
1007
+ uint32_t height ;
1008
+ uint32_t start_x ;
1009
+ uint32_t start_y ;
1010
+ /*output*/
1011
+ uint32_t num_planes ;
1012
+ uint32_t plane_start_x [4 ];
1013
+ uint32_t plane_start_y [4 ];
1014
+ uint32_t plane_width [4 ]; /*width in bytes*/
1015
+ uint32_t plane_height [4 ]; /*lines*/
1016
+ uint32_t reserved [4 ];
1017
+ } TracePictureLayout ;
1018
+
1019
+ static void va_TraceRetrieveImageInfo (TracePictureLayout * pLayout )
1020
+ {
1021
+ uint32_t fourcc = pLayout -> fourcc ;
1022
+ uint32_t width = pLayout -> width ;
1023
+ uint32_t height = pLayout -> height ;
1024
+ uint32_t start_x = pLayout -> start_x ;
1025
+ uint32_t start_y = pLayout -> start_y ;
1026
+
1027
+ if ((!fourcc ) || (!width ) || (!height )) {
1028
+ pLayout -> num_planes = 0 ;
1029
+ return ;
1030
+ }
1031
+ /* set initial values*/
1032
+ pLayout -> plane_width [0 ] = width ;
1033
+ pLayout -> plane_height [0 ] = height ;
1034
+ pLayout -> plane_start_x [0 ] = start_x ;
1035
+ pLayout -> plane_start_y [0 ] = start_y ;
1036
+
1037
+ pLayout -> num_planes = 1 ;
1038
+
1039
+ switch (fourcc ) {
1040
+ case VA_FOURCC_NV12 :
1041
+ case VA_FOURCC_NV21 :
1042
+ pLayout -> plane_width [1 ] = width ;
1043
+ pLayout -> plane_height [1 ] = height / 2 ;
1044
+ pLayout -> plane_start_x [1 ] = start_x ;
1045
+ pLayout -> plane_start_y [1 ] = start_y / 2 ;
1046
+ pLayout -> num_planes = 2 ;
1047
+ break ;
1048
+ case VA_FOURCC_RGBA :
1049
+ case VA_FOURCC_RGBX :
1050
+ case VA_FOURCC_BGRA :
1051
+ case VA_FOURCC_BGRX :
1052
+ case VA_FOURCC_ARGB :
1053
+ case VA_FOURCC_XRGB :
1054
+ case VA_FOURCC_ABGR :
1055
+ case VA_FOURCC_XBGR :
1056
+ case VA_FOURCC_AYUV :
1057
+ case VA_FOURCC_Y410 :
1058
+ case VA_FOURCC_A2R10G10B10 :
1059
+ case VA_FOURCC_A2B10G10R10 :
1060
+ case VA_FOURCC_X2R10G10B10 :
1061
+ case VA_FOURCC_X2B10G10R10 :
1062
+ case VA_FOURCC_XYUV :
1063
+ pLayout -> plane_width [0 ] = width * 4 ;
1064
+ pLayout -> plane_start_x [0 ] = start_x * 4 ;
1065
+ break ;
1066
+
1067
+ case VA_FOURCC_UYVY :
1068
+ case VA_FOURCC_YUY2 :
1069
+ case VA_FOURCC_Y16 :
1070
+ case VA_FOURCC_VYUY :
1071
+ case VA_FOURCC_YVYU :
1072
+ pLayout -> plane_width [0 ] = width * 2 ;
1073
+ pLayout -> plane_start_x [0 ] = start_x * 2 ;
1074
+ break ;
1075
+
1076
+ case VA_FOURCC_YV12 :
1077
+ case VA_FOURCC_I420 :
1078
+ case VA_FOURCC_IMC3 :
1079
+ case VA_FOURCC_411P :
1080
+ case VA_FOURCC_411R :
1081
+ pLayout -> plane_width [1 ] = width / 2 ;
1082
+ pLayout -> plane_width [2 ] = width / 2 ;
1083
+ pLayout -> plane_height [1 ] = height / 2 ;
1084
+ pLayout -> plane_height [2 ] = height / 2 ;
1085
+ pLayout -> plane_start_x [1 ] = start_x / 2 ;
1086
+ pLayout -> plane_start_x [2 ] = start_x / 2 ;
1087
+ pLayout -> plane_start_y [1 ] = start_y / 2 ;
1088
+ pLayout -> plane_start_y [2 ] = start_y / 2 ;
1089
+ pLayout -> num_planes = 3 ;
1090
+ break ;
1091
+
1092
+ case VA_FOURCC_P208 :
1093
+ pLayout -> plane_width [1 ] = width ;
1094
+ pLayout -> plane_height [1 ] = height ;
1095
+ pLayout -> plane_start_x [1 ] = start_x ;
1096
+ pLayout -> plane_start_y [1 ] = start_y ;
1097
+ pLayout -> num_planes = 2 ;
1098
+ break ;
1099
+
1100
+ case VA_FOURCC_YV32 :
1101
+ pLayout -> plane_width [1 ] =
1102
+ pLayout -> plane_width [2 ] =
1103
+ pLayout -> plane_width [3 ] = width ;
1104
+ pLayout -> plane_height [1 ] =
1105
+ pLayout -> plane_height [2 ] =
1106
+ pLayout -> plane_height [3 ] = height ;
1107
+ pLayout -> plane_start_x [1 ] =
1108
+ pLayout -> plane_start_x [2 ] =
1109
+ pLayout -> plane_start_x [3 ] = start_x ;
1110
+ pLayout -> plane_start_y [1 ] =
1111
+ pLayout -> plane_start_y [2 ] =
1112
+ pLayout -> plane_start_y [3 ] = start_y ;
1113
+ pLayout -> num_planes = 4 ;
1114
+ break ;
1115
+
1116
+
1117
+ case VA_FOURCC_YV24 :
1118
+ case VA_FOURCC_444P :
1119
+ case VA_FOURCC_RGBP :
1120
+ case VA_FOURCC_BGRP :
1121
+ pLayout -> plane_width [1 ] =
1122
+ pLayout -> plane_width [2 ] = width ;
1123
+ pLayout -> plane_height [1 ] =
1124
+ pLayout -> plane_height [2 ] = height ;
1125
+ pLayout -> plane_start_x [1 ] =
1126
+ pLayout -> plane_start_x [2 ] = start_x ;
1127
+ pLayout -> plane_start_y [1 ] =
1128
+ pLayout -> plane_start_y [2 ] = start_y ;
1129
+ pLayout -> num_planes = 3 ;
1130
+ break ;
1131
+
1132
+ case VA_FOURCC_422H :
1133
+ pLayout -> plane_width [1 ] =
1134
+ pLayout -> plane_width [2 ] = width / 2 ;
1135
+ pLayout -> plane_height [1 ] =
1136
+ pLayout -> plane_height [2 ] = height ;
1137
+ pLayout -> plane_start_x [1 ] =
1138
+ pLayout -> plane_start_x [2 ] = start_x / 2 ;
1139
+ pLayout -> plane_start_y [1 ] =
1140
+ pLayout -> plane_start_y [2 ] = start_y ;
1141
+ pLayout -> num_planes = 3 ;
1142
+ break ;
1143
+ case VA_FOURCC_422V :
1144
+ pLayout -> plane_width [1 ] =
1145
+ pLayout -> plane_width [2 ] = width ;
1146
+ pLayout -> plane_height [1 ] =
1147
+ pLayout -> plane_height [2 ] = height / 2 ;
1148
+ pLayout -> plane_start_x [1 ] =
1149
+ pLayout -> plane_start_x [2 ] = start_x ;
1150
+ pLayout -> plane_start_y [1 ] =
1151
+ pLayout -> plane_start_y [2 ] = start_y / 2 ;
1152
+ pLayout -> num_planes = 3 ;
1153
+ break ;
1154
+ case VA_FOURCC_RGB565 :
1155
+ case VA_FOURCC_BGR565 :
1156
+ pLayout -> plane_width [0 ] = width * 2 ;
1157
+ pLayout -> plane_start_x [0 ] = start_x * 2 ;
1158
+ break ;
1159
+
1160
+ case VA_FOURCC_Y210 :
1161
+ case VA_FOURCC_Y212 :
1162
+ case VA_FOURCC_Y216 :
1163
+ case VA_FOURCC_Y412 :
1164
+ case VA_FOURCC_Y416 :
1165
+ pLayout -> plane_width [0 ] = width * 8 ;
1166
+ pLayout -> plane_start_x [0 ] = start_x * 8 ;
1167
+ break ;
1168
+
1169
+ case VA_FOURCC_YV16 :
1170
+ pLayout -> plane_width [1 ] =
1171
+ pLayout -> plane_width [2 ] = width / 2 ;
1172
+ pLayout -> plane_height [1 ] =
1173
+ pLayout -> plane_height [2 ] = height ;
1174
+ pLayout -> plane_start_x [1 ] =
1175
+ pLayout -> plane_start_x [2 ] = start_x / 2 ;
1176
+ pLayout -> plane_start_y [1 ] =
1177
+ pLayout -> plane_start_y [2 ] = start_y ;
1178
+ pLayout -> num_planes = 3 ;
1179
+ break ;
1180
+ case VA_FOURCC_P010 :
1181
+ case VA_FOURCC_P012 :
1182
+ case VA_FOURCC_P016 :
1183
+ pLayout -> plane_width [0 ] = width * 2 ;
1184
+ pLayout -> plane_width [1 ] = width * 2 ;
1185
+ pLayout -> plane_height [1 ] = height / 2 ;
1186
+ pLayout -> plane_start_x [0 ] = start_x * 2 ;
1187
+ pLayout -> plane_start_x [1 ] = start_x * 2 ;
1188
+ pLayout -> plane_start_y [1 ] = start_y / 2 ;
1189
+ pLayout -> num_planes = 2 ;
1190
+ break ;
1191
+ case VA_FOURCC_I010 :
1192
+ pLayout -> plane_width [0 ] = width * 2 ;
1193
+ pLayout -> plane_width [1 ] =
1194
+ pLayout -> plane_width [2 ] = width ;
1195
+ pLayout -> plane_height [0 ] = height ;
1196
+ pLayout -> plane_height [1 ] =
1197
+ pLayout -> plane_height [2 ] = height / 2 ;
1198
+ pLayout -> plane_start_x [0 ] = start_x * 2 ;
1199
+ pLayout -> plane_start_x [1 ] =
1200
+ pLayout -> plane_start_x [2 ] = start_x ;
1201
+ pLayout -> plane_start_y [0 ] = start_y ;
1202
+ pLayout -> plane_start_y [1 ] =
1203
+ pLayout -> plane_start_y [2 ] = start_y / 2 ;
1204
+ pLayout -> num_planes = 3 ;
1205
+
1206
+ break ;
1207
+
1208
+ case VA_FOURCC_ARGB64 :
1209
+ case VA_FOURCC_ABGR64 :
1210
+ pLayout -> plane_width [0 ] =
1211
+ pLayout -> plane_width [1 ] =
1212
+ pLayout -> plane_width [2 ] =
1213
+ pLayout -> plane_width [3 ] = width * 2 ;
1214
+ pLayout -> plane_height [1 ] =
1215
+ pLayout -> plane_height [2 ] =
1216
+ pLayout -> plane_height [3 ] = height ;
1217
+ pLayout -> plane_start_x [0 ] =
1218
+ pLayout -> plane_start_x [1 ] =
1219
+ pLayout -> plane_start_x [2 ] =
1220
+ pLayout -> plane_start_x [3 ] = start_x * 2 ;
1221
+ pLayout -> plane_start_y [1 ] =
1222
+ pLayout -> plane_start_y [2 ] =
1223
+ pLayout -> plane_start_y [3 ] = start_y ;
1224
+ pLayout -> num_planes = 4 ;
1225
+ break ;
1226
+ case VA_FOURCC_Q416 :
1227
+ pLayout -> plane_width [0 ] =
1228
+ pLayout -> plane_width [1 ] =
1229
+ pLayout -> plane_width [2 ] = width * 2 ;
1230
+ pLayout -> plane_height [1 ] =
1231
+ pLayout -> plane_height [2 ] = height ;
1232
+ pLayout -> plane_start_x [0 ] =
1233
+ pLayout -> plane_start_x [1 ] =
1234
+ pLayout -> plane_start_x [2 ] = start_x * 2 ;
1235
+ pLayout -> plane_start_y [1 ] =
1236
+ pLayout -> plane_start_y [2 ] = start_y ;
1237
+ break ;
1238
+
1239
+ default : /*Y800 Y8*/
1240
+ break ;
1241
+ }
1242
+ }
1243
+
1003
1244
static void va_TraceSurface (VADisplay dpy , VAContextID context )
1004
1245
{
1005
1246
unsigned int i ;
@@ -1012,8 +1253,8 @@ static void va_TraceSurface(VADisplay dpy, VAContextID context)
1012
1253
unsigned int chroma_v_offset ;
1013
1254
unsigned int buffer_name ;
1014
1255
void * buffer = NULL ;
1015
- unsigned char * Y_data , * UV_data , * tmp ;
1016
- unsigned int pixel_byte ;
1256
+ unsigned char * Y_data , * U_data , * V_data , * tmp ;
1257
+ TracePictureLayout layout ;
1017
1258
VAStatus va_status ;
1018
1259
DPY2TRACECTX (dpy , context , VA_INVALID_ID );
1019
1260
@@ -1058,36 +1299,48 @@ static void va_TraceSurface(VADisplay dpy, VAContextID context)
1058
1299
va_TraceMsg (trace_ctx , NULL );
1059
1300
1060
1301
Y_data = (unsigned char * )buffer ;
1061
- UV_data = (unsigned char * )buffer + chroma_u_offset ;
1302
+ U_data = (unsigned char * )buffer + chroma_u_offset ;
1303
+ V_data = (unsigned char * )buffer + chroma_v_offset ;
1062
1304
1063
- if (fourcc == VA_FOURCC_Y410 )
1064
- pixel_byte = 4 ;
1065
- else if (fourcc == VA_FOURCC_P010 )
1066
- pixel_byte = 2 ;
1067
- else
1068
- pixel_byte = 1 ;
1305
+ layout .width = trace_ctx -> trace_surface_width ;
1306
+ layout .height = trace_ctx -> trace_surface_height ;
1307
+ layout .start_x = trace_ctx -> trace_surface_xoff ;
1308
+ layout .start_y = trace_ctx -> trace_surface_yoff ;
1309
+ layout .fourcc = fourcc ;
1069
1310
1070
- tmp = Y_data + luma_stride * trace_ctx -> trace_surface_yoff ;
1311
+ va_TraceRetrieveImageInfo ( & layout ) ;
1071
1312
1072
- for (i = 0 ; i < trace_ctx -> trace_surface_height ; i ++ ) {
1073
- fwrite (tmp + trace_ctx -> trace_surface_xoff ,
1074
- trace_ctx -> trace_surface_width ,
1075
- pixel_byte , trace_ctx -> trace_fp_surface );
1313
+ tmp = Y_data + luma_stride * layout .plane_start_y [0 ];
1314
+
1315
+ for (i = 0 ; i < layout .plane_height [0 ]; i ++ ) {
1316
+ fwrite (tmp + layout .plane_start_x [0 ],
1317
+ layout .plane_width [0 ],
1318
+ 1 , trace_ctx -> trace_fp_surface );
1076
1319
1077
1320
tmp += luma_stride ;
1078
1321
}
1079
1322
1080
- tmp = UV_data + chroma_u_stride * trace_ctx -> trace_surface_yoff / 2 ;
1081
- if (fourcc == VA_FOURCC_NV12 || fourcc == VA_FOURCC_P010 ) {
1082
- for (i = 0 ; i < trace_ctx -> trace_surface_height / 2 ; i ++ ) {
1083
- fwrite (tmp + trace_ctx -> trace_surface_xoff ,
1084
- trace_ctx -> trace_surface_width ,
1085
- pixel_byte , trace_ctx -> trace_fp_surface );
1086
-
1323
+ if (layout .num_planes > 1 ) {
1324
+ tmp = U_data + chroma_u_stride * layout .plane_start_y [1 ];
1325
+ for (i = 0 ; i < layout .plane_height [1 ]; i ++ ) {
1326
+ fwrite (tmp + layout .plane_start_x [1 ],
1327
+ layout .plane_width [1 ],
1328
+ 1 , trace_ctx -> trace_fp_surface );
1087
1329
tmp += chroma_u_stride ;
1088
1330
}
1089
1331
}
1090
1332
1333
+ if (layout .num_planes > 2 ) {
1334
+ tmp = V_data + chroma_v_stride * layout .plane_start_y [2 ];
1335
+ for (i = 0 ; i < layout .plane_height [2 ]; i ++ ) {
1336
+ fwrite (tmp + layout .plane_start_x [2 ],
1337
+ layout .plane_width [2 ],
1338
+ 1 , trace_ctx -> trace_fp_surface );
1339
+ tmp += chroma_v_stride ;
1340
+ }
1341
+ }
1342
+
1343
+
1091
1344
fflush (trace_ctx -> trace_fp_surface );
1092
1345
1093
1346
vaUnlockSurface (dpy , trace_ctx -> trace_rendertarget );
0 commit comments