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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
|
diff -uNr ticodecplugin/configure.ac ticodecplugin.new/configure.ac
--- ticodecplugin/configure.ac 2009-09-05 00:04:51.000000000 -0500
+++ ticodecplugin.new/configure.ac 2009-10-28 06:35:20.000000000 -0500
@@ -25,6 +25,7 @@
AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
AM_CONFIG_HEADER(config.h)
+AM_PROG_AS
dnl check for tools
AC_PROG_CC
diff -uNr ticodecplugin/src/gstticodecplugin.c ticodecplugin.new/src/gstticodecplugin.c
--- ticodecplugin/src/gstticodecplugin.c 2009-10-28 06:27:14.000000000 -0500
+++ ticodecplugin.new/src/gstticodecplugin.c 2009-10-28 06:36:28.000000000 -0500
@@ -47,6 +47,7 @@
#include "gsttiaudenc1.h"
#include "gsttividresize.h"
#include "gsttidmaiperf.h"
+#include "omapfb.h"
/* entry point to initialize the plug-in
* initialize the plug-in itself
@@ -161,6 +162,13 @@
GST_TYPE_DMAIPERF))
return FALSE;
+ env_value = getenv("GST_omapdmaifbsink_DISABLE");
+
+ if ((!env_value || strcmp(env_value,"1")) && !gst_element_register(
+ TICodecPlugin, "omapdmaifbsink", GST_RANK_PRIMARY,
+ GST_OMAPFB_SINK_TYPE))
+ return FALSE;
+
return TRUE;
}
diff -uNr ticodecplugin/src/omapfb.c ticodecplugin.new/src/omapfb.c
--- ticodecplugin/src/omapfb.c 1969-12-31 18:00:00.000000000 -0600
+++ ticodecplugin.new/src/omapfb.c 2009-10-28 06:35:20.000000000 -0500
@@ -0,0 +1,1005 @@
+/*
+ * Copyright (C) 2008 Felipe Contreras <felipe.contreras@gmail.com>
+ * Copyright (C) 2009 Tim Yamin <plasm@roo.me.uk>
+ * Copyright (C) 2009 Brijesh Singh <brijesh.ksingh@gmail.com>
+ *
+ * X code largely copied from ximagesink by Julien Moutte and
+ * vo_omapfb.c by Gregoire Gentil.
+ *
+ * Use DMAI hw framecopy module to copy the dmai transport buffers.
+ *
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <malloc.h>
+#include <stdlib.h>
+
+#include "omapfb.h"
+#include <gst/interfaces/xoverlay.h>
+
+static GstVideoSinkClass *parent_class = NULL;
+
+extern void yuv420_to_yuv422(__uint8_t *yuv, __uint8_t *y, __uint8_t *u, __uint8_t *v,
+ int w, int h, int yw, int cw, int dw);
+
+static void x11_get_window_abs_position(Display *display, Window window,
+ int *wx, int *wy, int *ww, int *wh)
+{
+ Window root, parent;
+ Window *child;
+ unsigned int n_children;
+ XWindowAttributes attribs;
+
+ /* Get window attributes */
+ XGetWindowAttributes(display, window, &attribs);
+
+ /* Get relative position of given window */
+ *wx = attribs.x;
+ *wy = attribs.y;
+ if (ww)
+ *ww = attribs.width;
+ if (wh)
+ *wh = attribs.height;
+
+ /* Query window tree information */
+ XQueryTree(display, window, &root, &parent, &child, &n_children);
+ if (parent)
+ {
+ int x, y;
+
+ /* If we have a parent we must go there and discover his position */
+ x11_get_window_abs_position(display, parent, &x, &y, NULL, NULL);
+ *wx += x;
+ *wy += y;
+ }
+
+ /* If we had children, free them */
+ if(n_children)
+ XFree(child);
+}
+
+static GstXWindow *
+gst_omapfbsink_xwindow_new (GstOmapFbSink * omapfbsink, gint width, gint height)
+{
+ GstXWindow *xwindow = NULL;
+ XGCValues values;
+
+ if(!omapfbsink->xcontext)
+ return NULL;
+
+ xwindow = g_new0 (GstXWindow, 1);
+ xwindow->width = width;
+ xwindow->height = height;
+ xwindow->internal = TRUE;
+
+ g_mutex_lock (omapfbsink->x_lock);
+ xwindow->win = XCreateSimpleWindow (omapfbsink->xcontext->disp,
+ omapfbsink->xcontext->root,
+ 0, 0, xwindow->width, xwindow->height,
+ 0, 0, omapfbsink->colorKey);
+
+ /* We have to do that to prevent X from redrawing the background on
+ ConfigureNotify. This takes away flickering of video when resizing. */
+ XSetWindowBackgroundPixmap (omapfbsink->xcontext->disp, xwindow->win, None);
+
+ if (omapfbsink->handle_events) {
+ Atom wm_delete;
+
+ XSelectInput (omapfbsink->xcontext->disp, xwindow->win, ExposureMask |
+ StructureNotifyMask | PointerMotionMask | KeyPressMask |
+ KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
+
+ /* Tell the window manager we'd like delete client messages instead of
+ * being killed */
+ wm_delete = XInternAtom (omapfbsink->xcontext->disp,
+ "WM_DELETE_WINDOW", False);
+ (void) XSetWMProtocols (omapfbsink->xcontext->disp, xwindow->win,
+ &wm_delete, 1);
+ }
+
+ xwindow->gc = XCreateGC (omapfbsink->xcontext->disp, xwindow->win,
+ 0, &values);
+
+ XMapRaised (omapfbsink->xcontext->disp, xwindow->win);
+ XSync (omapfbsink->xcontext->disp, FALSE);
+
+ g_mutex_unlock (omapfbsink->x_lock);
+ gst_x_overlay_got_xwindow_id (GST_X_OVERLAY (omapfbsink), xwindow->win);
+
+ return xwindow;
+}
+
+static gboolean gst_omapfbsink_update_plane (GstOmapFbSink *omapfbsink)
+{
+ int wx, wy, ww, wh;
+ if (!omapfbsink->xcontext)
+ {
+ if (ioctl (omapfbsink->overlay_fd, OMAPFB_SETUP_PLANE, &omapfbsink->plane_info))
+ return FALSE;
+ return TRUE;
+ }
+
+ if (omapfbsink->plane_info.enabled != 1)
+ return FALSE;
+
+ x11_get_window_abs_position(omapfbsink->xcontext->disp,
+ omapfbsink->xwindow->win, &wx, &wy, &ww, &wh);
+
+ if (wx != omapfbsink->xwindow->wx || wy != omapfbsink->xwindow->wy ||
+ wh != omapfbsink->xwindow->height || ww != omapfbsink->xwindow->width) {
+ omapfbsink->plane_info.out_width = omapfbsink->xwindow->width = ww;
+ omapfbsink->plane_info.out_height = omapfbsink->xwindow->height = wh;
+ omapfbsink->plane_info.pos_x = omapfbsink->xwindow->wx = wx;
+ omapfbsink->plane_info.pos_y = omapfbsink->xwindow->wy = wy;
+
+ GST_DEBUG_OBJECT(omapfbsink, "updating geometry to: (%d,%d) %dx%d", wx, wy, ww, wh);
+
+ XSetForeground (omapfbsink->xcontext->disp, omapfbsink->xwindow->gc, omapfbsink->colorKey);
+ XFillRectangle (omapfbsink->xcontext->disp, omapfbsink->xwindow->win, omapfbsink->xwindow->gc, 0, 0, ww, wh);
+
+ if (ioctl (omapfbsink->overlay_fd, OMAPFB_SETUP_PLANE, &omapfbsink->plane_info))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+gst_omapfbsink_expose (GstXOverlay * overlay)
+{
+ gst_omapfbsink_update_plane(GST_OMAPFB_SINK (overlay));
+}
+
+static void
+gst_omapfbsink_xwindow_destroy (GstOmapFbSink * omapfbsink,
+ GstXWindow * xwindow)
+{
+ g_return_if_fail (xwindow != NULL);
+ g_mutex_lock (omapfbsink->x_lock);
+
+ /* If we did not create that window we just free the GC and let it live */
+ if (xwindow->internal)
+ XDestroyWindow (omapfbsink->xcontext->disp, xwindow->win);
+ else
+ XSelectInput (omapfbsink->xcontext->disp, xwindow->win, 0);
+
+ XFreeGC (omapfbsink->xcontext->disp, xwindow->gc);
+ XSync (omapfbsink->xcontext->disp, FALSE);
+ g_mutex_unlock (omapfbsink->x_lock);
+ g_free (xwindow);
+}
+
+/* This function handles XEvents that might be in the queue. It generates
+ GstEvent that will be sent upstream in the pipeline to handle interactivity
+ and navigation.*/
+static void
+gst_omapfbsink_handle_xevents (GstOmapFbSink * omapfbsink)
+{
+ XEvent e;
+ g_mutex_lock (omapfbsink->flow_lock);
+ g_mutex_lock (omapfbsink->x_lock);
+
+ while (XCheckWindowEvent (omapfbsink->xcontext->disp,
+ omapfbsink->xwindow->win, ExposureMask | StructureNotifyMask, &e)) {
+ switch (e.type) {
+ case Expose:
+ case ConfigureNotify:
+ gst_omapfbsink_update_plane (omapfbsink);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Handle Display events */
+ while (XPending (omapfbsink->xcontext->disp)) {
+ XNextEvent (omapfbsink->xcontext->disp, &e);
+
+ switch (e.type) {
+ case ClientMessage:{
+ Atom wm_delete;
+
+ wm_delete = XInternAtom (omapfbsink->xcontext->disp,
+ "WM_DELETE_WINDOW", False);
+ if (wm_delete == (Atom) e.xclient.data.l[0]) {
+ /* Handle window deletion by posting an error on the bus */
+ GST_ELEMENT_ERROR (omapfbsink, RESOURCE, NOT_FOUND,
+ ("Output window was closed"), (NULL));
+
+ g_mutex_unlock (omapfbsink->x_lock);
+ gst_omapfbsink_xwindow_destroy (omapfbsink, omapfbsink->xwindow);
+ omapfbsink->xwindow = NULL;
+ g_mutex_lock (omapfbsink->x_lock);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ g_mutex_unlock (omapfbsink->x_lock);
+ g_mutex_unlock (omapfbsink->flow_lock);
+}
+
+static gpointer
+gst_omapfbsink_event_thread (GstOmapFbSink * omapfbsink)
+{
+ GST_OBJECT_LOCK (omapfbsink);
+ while (omapfbsink->running) {
+ GST_OBJECT_UNLOCK (omapfbsink);
+
+ if (omapfbsink->xwindow)
+ gst_omapfbsink_handle_xevents (omapfbsink);
+ g_usleep (100000);
+
+ GST_OBJECT_LOCK (omapfbsink);
+ }
+ GST_OBJECT_UNLOCK (omapfbsink);
+
+ return NULL;
+}
+
+/* This function gets the X Display and global info about it. Everything is
+ stored in our object and will be cleaned when the object is disposed. */
+static GstXContext *
+gst_omapfbsink_xcontext_get (GstOmapFbSink * omapfbsink)
+{
+ GstXContext *xcontext = g_new0 (GstXContext, 1);
+ g_mutex_lock (omapfbsink->x_lock);
+
+ xcontext->disp = XOpenDisplay (omapfbsink->display_name);
+
+ if (!xcontext->disp) {
+ g_mutex_unlock (omapfbsink->x_lock);
+ g_free (xcontext);
+ GST_ELEMENT_WARNING (omapfbsink, RESOURCE, WRITE,
+ ("Could not initialise X output"),
+ ("Could not open display"));
+ return NULL;
+ }
+
+ xcontext->screen = DefaultScreenOfDisplay (xcontext->disp);
+ xcontext->screen_num = DefaultScreen (xcontext->disp);
+ xcontext->visual = DefaultVisual (xcontext->disp, xcontext->screen_num);
+ xcontext->root = DefaultRootWindow (xcontext->disp);
+
+ xcontext->width = DisplayWidth (xcontext->disp, xcontext->screen_num);
+ xcontext->height = DisplayHeight (xcontext->disp, xcontext->screen_num);
+
+ g_mutex_unlock (omapfbsink->x_lock);
+
+ /* Setup our event listening thread */
+ GST_OBJECT_LOCK (omapfbsink);
+ omapfbsink->running = TRUE;
+ omapfbsink->event_thread = g_thread_create (
+ (GThreadFunc) gst_omapfbsink_event_thread, omapfbsink, TRUE, NULL);
+ GST_OBJECT_UNLOCK (omapfbsink);
+
+ return xcontext;
+}
+
+static void
+gst_omapfbsink_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
+{
+ GstOmapFbSink *omapfbsink = GST_OMAPFB_SINK (overlay);
+ GstXWindow *xwindow = NULL;
+ XWindowAttributes attr;
+
+ /* If we already use that window, return */
+ if (omapfbsink->xwindow && (xwindow_id == omapfbsink->xwindow->win))
+ return;
+
+ /* If the element has not initialized the X11 context try to do so */
+ if (!omapfbsink->xcontext &&
+ !(omapfbsink->xcontext = gst_omapfbsink_xcontext_get (omapfbsink))) {
+ g_mutex_unlock (omapfbsink->flow_lock);
+ return;
+ }
+
+ /* If a window is there already we destroy it */
+ if (omapfbsink->xwindow) {
+ gst_omapfbsink_xwindow_destroy (omapfbsink, omapfbsink->xwindow);
+ omapfbsink->xwindow = NULL;
+ }
+
+ /* If the xid is 0 we go back to an internal window */
+ if (xwindow_id == 0) {
+ /* If no width/height caps nego did not happen window will be created
+ during caps nego then */
+ if (GST_VIDEO_SINK_WIDTH (omapfbsink) && GST_VIDEO_SINK_HEIGHT (omapfbsink)) {
+ xwindow = gst_omapfbsink_xwindow_new (omapfbsink,
+ GST_VIDEO_SINK_WIDTH (omapfbsink),
+ GST_VIDEO_SINK_HEIGHT (omapfbsink));
+ }
+ } else {
+ xwindow = g_new0 (GstXWindow, 1);
+ xwindow->wx = xwindow->wy = -1;
+ xwindow->win = xwindow_id;
+
+ /* We get window geometry, set the event we want to receive,
+ and create a GC */
+ g_mutex_lock (omapfbsink->x_lock);
+ XGetWindowAttributes (omapfbsink->xcontext->disp, xwindow->win, &attr);
+ xwindow->width = attr.width;
+ xwindow->height = attr.height;
+ xwindow->internal = FALSE;
+ if (omapfbsink->handle_events) {
+ XSelectInput (omapfbsink->xcontext->disp, xwindow->win, ExposureMask |
+ StructureNotifyMask | PointerMotionMask | KeyPressMask |
+ KeyReleaseMask);
+ }
+
+ xwindow->gc = XCreateGC (omapfbsink->xcontext->disp, xwindow->win, 0, NULL);
+ g_mutex_unlock (omapfbsink->x_lock);
+ }
+
+ if (xwindow) {
+ omapfbsink->xwindow = xwindow;
+
+ g_mutex_lock (omapfbsink->x_lock);
+ gst_omapfbsink_update_plane(omapfbsink);
+ g_mutex_unlock (omapfbsink->x_lock);
+ }
+}
+
+static void
+gst_omapfbsink_xwindow_clear (GstOmapFbSink * omapfbsink,
+ GstXWindow * xwindow)
+{
+ g_return_if_fail (xwindow != NULL);
+ g_mutex_lock (omapfbsink->x_lock);
+
+ XSetForeground (omapfbsink->xcontext->disp, xwindow->gc,
+ XBlackPixel (omapfbsink->xcontext->disp,
+ omapfbsink->xcontext->screen_num));
+
+ XFillRectangle (omapfbsink->xcontext->disp, xwindow->win, xwindow->gc,
+ 0, 0, xwindow->width, xwindow->height);
+
+ XSync (omapfbsink->xcontext->disp, FALSE);
+ g_mutex_unlock (omapfbsink->x_lock);
+}
+
+static void
+gst_omapfbsink_set_event_handling (GstXOverlay * overlay,
+ gboolean handle_events)
+{
+ GstOmapFbSink *omapfbsink = GST_OMAPFB_SINK (overlay);
+ omapfbsink->handle_events = handle_events;
+
+ g_mutex_lock (omapfbsink->flow_lock);
+
+ if (G_UNLIKELY (!omapfbsink->xwindow)) {
+ g_mutex_unlock (omapfbsink->flow_lock);
+ return;
+ }
+
+ g_mutex_lock (omapfbsink->x_lock);
+
+ if (handle_events) {
+ if (omapfbsink->xwindow->internal) {
+ XSelectInput (omapfbsink->xcontext->disp, omapfbsink->xwindow->win,
+ ExposureMask | StructureNotifyMask | PointerMotionMask |
+ KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
+ } else {
+ XSelectInput (omapfbsink->xcontext->disp, omapfbsink->xwindow->win,
+ ExposureMask | StructureNotifyMask | PointerMotionMask |
+ KeyPressMask | KeyReleaseMask);
+ }
+ } else {
+ XSelectInput (omapfbsink->xcontext->disp, omapfbsink->xwindow->win, 0);
+ }
+
+ g_mutex_unlock (omapfbsink->x_lock);
+ g_mutex_unlock (omapfbsink->flow_lock);
+}
+
+static void
+gst_omapfbsink_xoverlay_init (GstXOverlayClass * iface)
+{
+ iface->set_xwindow_id = gst_omapfbsink_set_xwindow_id;
+ iface->expose = gst_omapfbsink_expose;
+ iface->handle_events = gst_omapfbsink_set_event_handling;
+}
+
+static GstCaps *
+generate_sink_template (void)
+{
+ GstCaps *caps;
+ GstStructure *struc;
+
+ caps = gst_caps_new_empty ();
+
+ struc = gst_structure_new ("video/x-raw-yuv",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30, 1,
+ NULL);
+
+ {
+ GValue list;
+ GValue val;
+
+ list.g_type = val.g_type = 0;
+
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, GST_TYPE_FOURCC);
+
+#if 0
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
+ gst_value_list_append_value (&list, &val);
+#else
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
+ gst_value_list_append_value (&list, &val);
+
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
+ gst_value_list_append_value (&list, &val);
+#endif
+
+ gst_structure_set_value (struc, "format", &list);
+
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
+
+ gst_caps_append_structure (caps, struc);
+
+ return caps;
+}
+
+static GstFlowReturn
+buffer_alloc (GstBaseSink *bsink,
+ guint64 offset,
+ guint size,
+ GstCaps *caps,
+ GstBuffer **buf)
+{
+ GstOmapFbSink *self;
+ GstBuffer *buffer = NULL;
+ GstFlowReturn ret = GST_FLOW_OK;
+ self = GST_OMAPFB_SINK (bsink);
+
+ if(self->row_skip) {
+ buffer = gst_buffer_new ();
+ GST_BUFFER_DATA (buffer) = self->buffer = self->framebuffer;
+ GST_BUFFER_SIZE (buffer) = self->buffer_size = size;
+ gst_buffer_set_caps (buffer, caps);
+ } else {
+ if(self->buffer && size == self->buffer_size) {
+ buffer = gst_buffer_new ();
+ GST_BUFFER_DATA (buffer) = self->buffer;
+ GST_BUFFER_SIZE (buffer) = size;
+ gst_buffer_set_caps (buffer, caps);
+ } else {
+ if(self->buffer)
+ free(self->buffer);
+ if(posix_memalign(&self->buffer, 16, (size_t) size) == 0) {
+ buffer = gst_buffer_new ();
+ GST_BUFFER_DATA (buffer) = self->buffer;
+ GST_BUFFER_SIZE (buffer) = self->buffer_size = size;
+ gst_buffer_set_caps (buffer, caps);
+ } else {
+ GST_ELEMENT_ERROR (self, RESOURCE, WRITE, ("Could not allocate aligned buf!"),
+ ("Could not alloc aligned buf!"));
+ }
+ }
+ }
+
+ *buf = buffer;
+ return ret;
+}
+
+static void
+x_memcpy (GstOmapFbSink *omapfbsink, __uint8_t *outBuf, __uint8_t *inBuf)
+{
+ BufferGfx_Attrs gfxAttrs = BufferGfx_Attrs_DEFAULT;
+ Buffer_Handle hInBuf = NULL, hOutBuf = NULL;
+ Framecopy_Attrs fcAttrs = Framecopy_Attrs_DEFAULT;
+ int size;
+
+ if (omapfbsink->hFc == NULL) {
+ fcAttrs.accel = TRUE;
+ omapfbsink->hFc = Framecopy_create(&fcAttrs);
+ if (omapfbsink->hFc == NULL) {
+ GST_ELEMENT_ERROR(omapfbsink, RESOURCE, WRITE, ("failed to create dmai framecopy handle"), ("failed to create dmai framecopy handle"));
+ goto cleanup;
+ }
+ }
+
+ gfxAttrs.bAttrs.reference = TRUE;
+ gfxAttrs.dim.width = GST_VIDEO_SINK_WIDTH (omapfbsink);
+ gfxAttrs.dim.height = GST_VIDEO_SINK_HEIGHT (omapfbsink);
+ gfxAttrs.colorSpace = ColorSpace_UYVY;
+ gfxAttrs.dim.lineLength = omapfbsink->fixinfo.line_length;
+ size = gfxAttrs.dim.height * gfxAttrs.dim.width * 2;
+
+ hInBuf = Buffer_create(size, BufferGfx_getBufferAttrs(&gfxAttrs));
+ if (hInBuf == NULL) {
+ GST_ELEMENT_ERROR(omapfbsink, RESOURCE, WRITE, ("Could not allocate refer dmai buffer"), ("Could not allocate refer dmai buffer"));
+ goto cleanup;
+ }
+ Buffer_setUserPtr(hInBuf, (Int8*) inBuf);
+ Buffer_setNumBytesUsed(hInBuf,Buffer_getSize(hInBuf));
+
+ hOutBuf = Buffer_create(size, BufferGfx_getBufferAttrs(&gfxAttrs));
+ if (hOutBuf == NULL) {
+ GST_ELEMENT_ERROR(omapfbsink, RESOURCE, WRITE, ("Could not allocate refer dmai buffer"), ("Could not allocate refer dmai buffer"));
+ goto cleanup;
+ }
+ Buffer_setUserPtr(hOutBuf, (Int8*) outBuf);
+ Buffer_setNumBytesUsed(hOutBuf,Buffer_getSize(hOutBuf));
+
+
+ if (Framecopy_config(omapfbsink->hFc, hInBuf, hOutBuf) < 0) {
+ GST_ELEMENT_ERROR(omapfbsink, RESOURCE, WRITE, ("failed to configure dmai framecopy handle"), ("failed to configure dmai framecopy handle"));
+ goto cleanup;
+ }
+
+ if (Framecopy_execute(omapfbsink->hFc, hInBuf, hOutBuf) < 0) {
+ GST_ELEMENT_ERROR(omapfbsink, RESOURCE, WRITE, ("failed to execute dmai framecopy handle"), ("failed to configure dmai framecopy handle"));
+ goto cleanup;
+ }
+ cleanup:
+
+ if (hInBuf)
+ Buffer_delete(hInBuf);
+ if (hOutBuf)
+ Buffer_delete(hOutBuf);
+}
+
+static GstFlowReturn
+render (GstBaseSink * bsink, GstBuffer * buf)
+{
+ int i, w, h;
+ GstOmapFbSink *omapfbsink = GST_OMAPFB_SINK(bsink);
+ __uint8_t *fb = omapfbsink->framebuffer, *data = GST_BUFFER_DATA(buf);
+ gboolean useXcopy = FALSE;
+
+ if (GST_IS_TIDMAIBUFFERTRANSPORT(buf)) {
+ GST_LOG("found dmai transport buffer, enabling hw framecopy.\n");
+ useXcopy = TRUE;
+ }
+
+ if(omapfbsink->plane_info.enabled == 2)
+ {
+ omapfbsink->plane_info.enabled = 1;
+
+ g_mutex_lock (omapfbsink->x_lock);
+ gst_omapfbsink_update_plane(omapfbsink);
+ g_mutex_unlock (omapfbsink->x_lock);
+ }
+
+ /* If a buffer which wasn't supplied by us is given to us to render with,
+ we need to copy to our buffer first so that memory alignment constraints
+ are met. */
+ if((data != omapfbsink->buffer && GST_BUFFER_SIZE(buf) <= omapfbsink->buffer_size) && !useXcopy)
+ {
+ memcpy(omapfbsink->buffer, data, GST_BUFFER_SIZE(buf));
+ data = omapfbsink->buffer;
+ }
+
+ /* buffer_alloc gave a direct buffer, so we have nothing to
+ do here... */
+ if(omapfbsink->row_skip)
+ return GST_FLOW_OK;
+
+ switch(omapfbsink->image_format) {
+ case GST_MAKE_FOURCC('I', '4', '2', '0'):
+ /* Convert to YUV422 and send to FB */
+
+ h = GST_VIDEO_SINK_HEIGHT (omapfbsink);
+ w = GST_VIDEO_SINK_WIDTH (omapfbsink);
+
+ __uint8_t *y, *u, *v;
+ y = data;
+ u = y + w * h;
+ v = u + w / 2 * h / 2;
+ yuv420_to_yuv422(fb, y, u, v, w & ~15, h, w, w / 2, omapfbsink->fixinfo.line_length);
+ break;
+
+ case GST_MAKE_FOURCC('U', 'Y', 'V', 'Y'):
+ /* Send to FB, taking into account line_length */
+ if (useXcopy) {
+ x_memcpy(omapfbsink, fb, data);
+ }
+ else {
+
+ w = 2 * GST_VIDEO_SINK_WIDTH (omapfbsink);
+ for(i = 0; i < GST_VIDEO_SINK_HEIGHT (omapfbsink); i++)
+ {
+ memcpy(fb, data, w);
+
+ fb += omapfbsink->fixinfo.line_length;
+ data += w;
+ }
+ }
+ break;
+ }
+
+ return GST_FLOW_OK;
+}
+
+static gboolean
+setcaps (GstBaseSink *bsink,
+ GstCaps *vscapslist)
+{
+ GstOmapFbSink *self;
+ GstStructure *structure;
+
+ gint width, height;
+ struct omapfb_color_key color_key;
+
+ self = GST_OMAPFB_SINK (bsink);
+
+ structure = gst_caps_get_structure (vscapslist, 0);
+
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
+
+ self->overlay_info.xres = MIN (self->varinfo.xres, width) & ~15;
+ self->overlay_info.yres = MIN (self->varinfo.yres, height) & ~15;
+ self->overlay_info.xres_virtual = self->overlay_info.xres;
+ self->overlay_info.yres_virtual = self->overlay_info.yres;
+
+ self->overlay_info.xoffset = 0;
+ self->overlay_info.yoffset = 0;
+
+ gst_structure_get_fourcc (structure, "format", &self->image_format);
+ switch(self->image_format) {
+ case GST_MAKE_FOURCC('I', '4', '2', '0'):
+ self->row_skip = FALSE; /* Colorspace conversion required */
+ self->overlay_info.nonstd = OMAPFB_COLOR_YUY422;
+ break;
+ case GST_MAKE_FOURCC('U', 'Y', 'V', 'Y'):
+ /* Can data be pushed straight to the FB or do we need to interleave? */
+ if (self->fixinfo.line_length != 2 * width)
+ self->row_skip = FALSE;
+ else
+ self->row_skip = TRUE;
+ self->overlay_info.nonstd = OMAPFB_COLOR_YUV422;
+ break;
+ }
+
+ if (ioctl (self->overlay_fd, FBIOPUT_VSCREENINFO, &self->overlay_info))
+ return FALSE;
+
+ GST_VIDEO_SINK_WIDTH (self) = width;
+ GST_VIDEO_SINK_HEIGHT (self) = height;
+ if (!self->xwindow) {
+ self->xwindow = gst_omapfbsink_xwindow_new (self,
+ GST_VIDEO_SINK_WIDTH (self), GST_VIDEO_SINK_HEIGHT (self));
+ }
+
+ color_key.channel_out = OMAPFB_CHANNEL_OUT_LCD;
+ color_key.background = 0x0;
+ color_key.trans_key = self->colorKey;
+ if (self->xwindow)
+ color_key.key_type = OMAPFB_COLOR_KEY_GFX_DST;
+ else
+ color_key.key_type = OMAPFB_COLOR_KEY_DISABLED;
+
+ if (ioctl (self->overlay_fd, OMAPFB_SET_COLOR_KEY, &color_key))
+ return FALSE;
+
+ self->plane_info.pos_x = 0;
+ self->plane_info.pos_y = 0;
+ self->plane_info.out_width = self->overlay_info.xres;
+ self->plane_info.out_height = self->overlay_info.yres;
+ self->plane_info.enabled = 2;
+
+ if (ioctl (self->overlay_fd, FBIOGET_FSCREENINFO, &self->fixinfo))
+ return FALSE;
+
+ self->enabled = TRUE;
+ return TRUE;
+}
+
+static gboolean
+start (GstBaseSink *bsink)
+{
+ GstOmapFbSink *self;
+ int fd;
+
+ self = GST_OMAPFB_SINK (bsink);
+
+ fd = open ("/dev/fb0", O_RDWR);
+
+ if (fd == -1)
+ return FALSE;
+
+ if (ioctl (fd, FBIOGET_VSCREENINFO, &self->varinfo))
+ {
+ close (fd);
+ return FALSE;
+ }
+
+ if (close (fd))
+ return FALSE;
+
+ self->overlay_fd = open ("/dev/fb1", O_RDWR);
+
+ if (self->overlay_fd == -1)
+ return FALSE;
+
+ if (ioctl (self->overlay_fd, FBIOGET_VSCREENINFO, &self->overlay_info))
+ return FALSE;
+
+ if (ioctl (self->overlay_fd, OMAPFB_QUERY_PLANE, &self->plane_info))
+ return FALSE;
+
+ if (ioctl (self->overlay_fd, OMAPFB_QUERY_MEM, &self->mem_info))
+ return FALSE;
+
+ self->framebuffer = mmap (NULL, self->mem_info.size, PROT_WRITE, MAP_SHARED, self->overlay_fd, 0);
+ if (self->framebuffer == MAP_FAILED)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+stop (GstBaseSink *bsink)
+{
+ GstOmapFbSink *self;
+
+ self = GST_OMAPFB_SINK (bsink);
+
+ if (self->enabled)
+ {
+ self->plane_info.enabled = 0;
+
+ if (ioctl (self->overlay_fd, OMAPFB_SETUP_PLANE, &self->plane_info))
+ return FALSE;
+ }
+
+ if (munmap (self->framebuffer, self->mem_info.size))
+ return FALSE;
+
+ if (close (self->overlay_fd))
+ return FALSE;
+
+ if (self->hFc)
+ Framecopy_delete(self->hFc);
+
+ return TRUE;
+}
+
+/* This function cleans the X context. Closing the Display and unrefing the
+ caps for supported formats. */
+static void
+gst_omapfbsink_xcontext_clear (GstOmapFbSink * omapfbsink)
+{
+ GstXContext *xcontext;
+ GST_OBJECT_LOCK (omapfbsink);
+ if (omapfbsink->xcontext == NULL) {
+ GST_OBJECT_UNLOCK (omapfbsink);
+ return;
+ }
+
+ xcontext = omapfbsink->xcontext;
+ omapfbsink->xcontext = NULL;
+
+ GST_OBJECT_UNLOCK (omapfbsink);
+ g_mutex_lock (omapfbsink->x_lock);
+
+ XCloseDisplay (xcontext->disp);
+ g_mutex_unlock (omapfbsink->x_lock);
+ g_free (xcontext);
+}
+
+static void
+gst_omapfbsink_reset (GstOmapFbSink *omapfbsink)
+{
+ GThread *thread;
+
+ GST_OBJECT_LOCK (omapfbsink);
+ omapfbsink->running = FALSE;
+ /* grab thread and mark it as NULL */
+ thread = omapfbsink->event_thread;
+ omapfbsink->event_thread = NULL;
+ GST_OBJECT_UNLOCK (omapfbsink);
+
+ /* Wait for our event thread to finish before we clean up our stuff. */
+ if (thread)
+ g_thread_join (thread);
+
+ g_mutex_lock (omapfbsink->flow_lock);
+ if (omapfbsink->xwindow) {
+ gst_omapfbsink_xwindow_clear (omapfbsink, omapfbsink->xwindow);
+ gst_omapfbsink_xwindow_destroy (omapfbsink, omapfbsink->xwindow);
+ omapfbsink->xwindow = NULL;
+ }
+ g_mutex_unlock (omapfbsink->flow_lock);
+ gst_omapfbsink_xcontext_clear (omapfbsink);
+}
+
+static GstStateChangeReturn
+gst_omapfbsink_change_state (GstElement * element, GstStateChange transition)
+{
+ GstOmapFbSink *omapfbsink;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GstXContext *xcontext = NULL;
+
+ omapfbsink = GST_OMAPFB_SINK (element);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+
+ /* Initializing the XContext */
+ if (omapfbsink->xcontext == NULL) {
+ xcontext = gst_omapfbsink_xcontext_get (omapfbsink);
+
+ GST_OBJECT_LOCK (omapfbsink);
+ omapfbsink->xcontext = xcontext;
+ GST_OBJECT_UNLOCK (omapfbsink);
+ }
+ break;
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ g_mutex_lock (omapfbsink->flow_lock);
+ if (omapfbsink->xwindow)
+ gst_omapfbsink_xwindow_clear (omapfbsink, omapfbsink->xwindow);
+ g_mutex_unlock (omapfbsink->flow_lock);
+ break;
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
+ break;
+ default:
+ break;
+ }
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+ break;
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ GST_VIDEO_SINK_WIDTH (omapfbsink) = 0;
+ GST_VIDEO_SINK_HEIGHT (omapfbsink) = 0;
+ break;
+ case GST_STATE_CHANGE_READY_TO_NULL:
+ gst_omapfbsink_reset (omapfbsink);
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+static void
+type_class_init (gpointer g_class,
+ gpointer class_data)
+{
+ GstElementClass *element_class;
+ GstBaseSinkClass *base_sink_class;
+
+ element_class = (GstElementClass *) g_class;
+ base_sink_class = (GstBaseSinkClass *) g_class;
+
+ parent_class = g_type_class_peek_parent (g_class);
+
+ base_sink_class->set_caps = GST_DEBUG_FUNCPTR (setcaps);
+ base_sink_class->buffer_alloc = GST_DEBUG_FUNCPTR (buffer_alloc);
+ base_sink_class->render = GST_DEBUG_FUNCPTR (render);
+ base_sink_class->start = GST_DEBUG_FUNCPTR (start);
+ base_sink_class->stop = GST_DEBUG_FUNCPTR (stop);
+
+ element_class->change_state = gst_omapfbsink_change_state;
+}
+
+static void
+type_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ {
+ GstElementDetails details;
+
+ details.longname = "Linux OMAP framebuffer sink";
+ details.klass = "Sink/Video";
+ details.description = "Renders video with omapfb";
+ details.author = "Felipe Contreras";
+
+ gst_element_class_set_details (element_class, &details);
+ }
+
+ {
+ GstPadTemplate *template;
+
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ generate_sink_template ());
+
+ gst_element_class_add_pad_template (element_class, template);
+ }
+}
+
+static gboolean
+gst_omapfbsink_interface_supported (GstImplementsInterface * iface, GType type)
+{
+ g_assert (type == GST_TYPE_X_OVERLAY);
+ return TRUE;
+}
+
+static void
+gst_omapfbsink_interface_init (GstImplementsInterfaceClass * klass)
+{
+ klass->supported = gst_omapfbsink_interface_supported;
+}
+
+static void
+gst_omapfbsink_init (GstOmapFbSink * omapfbsink)
+{
+ omapfbsink->display_name = NULL;
+ omapfbsink->xcontext = NULL;
+ omapfbsink->xwindow = NULL;
+
+ omapfbsink->event_thread = NULL;
+ omapfbsink->running = FALSE;
+
+ omapfbsink->x_lock = g_mutex_new ();
+ omapfbsink->flow_lock = g_mutex_new ();
+
+ omapfbsink->handle_events = TRUE;
+ omapfbsink->colorKey = 0xff0;
+
+ omapfbsink->plane_info.enabled = 0;
+ omapfbsink->row_skip = FALSE;
+
+ omapfbsink->buffer = NULL;
+ omapfbsink->buffer_size = 0;
+ omapfbsink->hFc = NULL;
+}
+
+GType
+gst_omapfbsink_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ GTypeInfo *type_info;
+ static const GInterfaceInfo iface_info = {
+ (GInterfaceInitFunc) gst_omapfbsink_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo overlay_info = {
+ (GInterfaceInitFunc) gst_omapfbsink_xoverlay_init,
+ NULL,
+ NULL,
+ };
+ type_info = g_new0 (GTypeInfo, 1);
+ type_info->class_size = sizeof (GstOmapFbSinkClass);
+ type_info->base_init = type_base_init;
+ type_info->class_init = type_class_init;
+ type_info->instance_size = sizeof (GstOmapFbSink);
+ type_info->instance_init = (GInstanceInitFunc) gst_omapfbsink_init;
+
+ type = g_type_register_static (GST_TYPE_BASE_SINK, "GstOmapFbSink", type_info, 0);
+ g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info);
+ g_type_add_interface_static (type, GST_TYPE_X_OVERLAY, &overlay_info);
+
+ g_free (type_info);
+ }
+
+ return type;
+}
diff -uNr ticodecplugin/src/omapfb.h ticodecplugin.new/src/omapfb.h
--- ticodecplugin/src/omapfb.h 1969-12-31 18:00:00.000000000 -0600
+++ ticodecplugin.new/src/omapfb.h 2009-10-28 06:35:20.000000000 -0500
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2008 Felipe Contreras <felipe.contreras@gmail.com>
+ *
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef GST_OMAPFB_H
+#define GST_OMAPFB_H
+
+#include <ti/sdo/dmai/BufferGfx.h>
+#include <ti/sdo/dmai/Framecopy.h>
+
+#include "gsttidmaibuffertransport.h"
+#include <gst/gst.h>
+#include <gst/video/gstvideosink.h>
+#include <gst/video/video.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <linux/fb.h>
+#include <linux/omapfb.h>
+
+
+G_BEGIN_DECLS
+
+#define GST_OMAPFB_SINK_TYPE (gst_omapfbsink_get_type ())
+#define GST_OMAPFB_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_OMAPFB_SINK_TYPE, GstOmapFbSink))
+
+typedef struct GstXContext GstXContext;
+typedef struct GstXWindow GstXWindow;
+typedef struct GstOmapFbSink GstOmapFbSink;
+typedef struct GstOmapFbSinkClass GstOmapFbSinkClass;
+
+/**
+ * GstXWindow:
+ * @win: the Window ID of this X11 window
+ * @width: the width in pixels of Window @win
+ * @height: the height in pixels of Window @win
+ * @internal: used to remember if Window @win was created internally or passed
+ * through the #GstXOverlay interface
+ * @gc: the Graphical Context of Window @win
+ *
+ * Structure used to store informations about a Window.
+ */
+struct GstXWindow {
+ Window win;
+ gint width, height;
+ gboolean internal;
+ GC gc;
+
+ gint wx, wy;
+};
+
+/**
+ * GstXContext:
+ * @disp: the X11 Display of this context
+ * @screen: the default Screen of Display @disp
+ * @screen_num: the Screen number of @screen
+ * @visual: the default Visual of Screen @screen
+ * @root: the root Window of Display @disp
+ * @white: the value of a white pixel on Screen @screen
+ * @black: the value of a black pixel on Screen @screen
+ * @depth: the color depth of Display @disp
+ * @bpp: the number of bits per pixel on Display @disp
+ * @endianness: the endianness of image bytes on Display @disp
+ * @width: the width in pixels of Display @disp
+ * @height: the height in pixels of Display @disp
+ *
+ * Structure used to store various informations collected/calculated for a
+ * Display.
+ */
+struct GstXContext {
+ Display *disp;
+ Screen *screen;
+ gint screen_num;
+
+ Visual *visual;
+ Window root;
+
+ gint depth;
+ gint bpp;
+
+ gint width, height;
+};
+
+struct GstOmapFbSink
+{
+ GstVideoSink videosink;
+
+ struct fb_fix_screeninfo fixinfo;
+ struct fb_var_screeninfo varinfo;
+ struct fb_var_screeninfo overlay_info;
+ struct omapfb_mem_info mem_info;
+ struct omapfb_plane_info plane_info;
+
+ int overlay_fd;
+ unsigned char *framebuffer;
+ gboolean enabled;
+
+ GMutex *x_lock;
+ GMutex *flow_lock;
+
+ GstXContext *xcontext;
+ GstXWindow *xwindow;
+
+ gulong colorKey;
+ char *display_name;
+ GThread *event_thread;
+
+ void *buffer;
+ guint buffer_size;
+ guint image_format;
+
+ gboolean row_skip;
+ gboolean handle_events;
+ gboolean running;
+ Framecopy_Handle hFc;
+};
+
+struct GstOmapFbSinkClass
+{
+ GstBaseSinkClass parent_class;
+};
+
+GType gst_omapfbsink_get_type (void);
+
+G_END_DECLS
+
+#endif /* GST_OMAPFB_H */
diff -uNr ticodecplugin/src/yuv.S ticodecplugin.new/src/yuv.S
--- ticodecplugin/src/yuv.S 1969-12-31 18:00:00.000000000 -0600
+++ ticodecplugin.new/src/yuv.S 2009-10-28 06:35:20.000000000 -0500
@@ -0,0 +1,117 @@
+/*
+ Copyright (C) 2008 Mans Rullgard
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use, copy,
+ modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+ .fpu neon
+ .text
+
+@ yuv420_to_yuv422(uint8_t *yuv, uint8_t *y, uint8_t *u, uint8_t *v,
+@ int w, int h, int yw, int cw, int dw)
+
+#define yuv r0
+#define y r1
+#define u r2
+#define v r3
+#define w r4
+#define h r5
+#define yw r6
+#define cw r7
+#define dw r8
+
+#define tyuv r9
+#define ty r10
+#define tu r11
+#define tv r12
+#define i lr
+
+ .global yuv420_to_yuv422
+ .func yuv420_to_yuv422
+yuv420_to_yuv422:
+ push {r4-r11,lr}
+ add r4, sp, #36
+ ldm r4, {r4-r8}
+1:
+ mov tu, u
+ mov tv, v
+ vld1.64 {d2}, [u,:64], cw @ u0
+ vld1.64 {d3}, [v,:64], cw @ v0
+ mov tyuv, yuv
+ mov ty, y
+ vzip.8 d2, d3 @ u0v0
+ mov i, #16
+2:
+ pld [y, #64]
+ vld1.64 {d0, d1}, [y,:128], yw @ y0
+ pld [u, #64]
+ subs i, i, #4
+ vld1.64 {d6}, [u,:64], cw @ u2
+ pld [y, #64]
+ vld1.64 {d4, d5}, [y,:128], yw @ y1
+ pld [v, #64]
+ vld1.64 {d7}, [v,:64], cw @ v2
+ pld [y, #64]
+ vld1.64 {d16,d17}, [y,:128], yw @ y2
+ vzip.8 d6, d7 @ u2v2
+ pld [u, #64]
+ vld1.64 {d22}, [u,:64], cw @ u4
+ pld [v, #64]
+ vld1.64 {d23}, [v,:64], cw @ v4
+ pld [y, #64]
+ vld1.64 {d20,d21}, [y,:128], yw @ y3
+ vmov q9, q3 @ u2v2
+ vzip.8 d22, d23 @ u4v4
+ vrhadd.u8 q3, q1, q3 @ u1v1
+ vzip.8 q0, q1 @ y0u0y0v0
+ vmov q12, q11 @ u4v4
+ vzip.8 q2, q3 @ y1u1y1v1
+ vrhadd.u8 q11, q9, q11 @ u3v3
+ vst1.64 {d0-d3}, [yuv,:128], dw @ y0u0y0v0
+ vzip.8 q8, q9 @ y2u2y2v2
+ vst1.64 {d4-d7}, [yuv,:128], dw @ y1u1y1v1
+ vzip.8 q10, q11 @ y3u3y3v3
+ vst1.64 {d16-d19}, [yuv,:128], dw @ y2u2y2v2
+ vmov q1, q12
+ vst1.64 {d20-d23}, [yuv,:128], dw @ y3u3y3v3
+ bgt 2b
+ subs w, w, #16
+ add yuv, tyuv, #32
+ add y, ty, #16
+ add u, tu, #8
+ add v, tv, #8
+ bgt 1b
+
+ ldr w, [sp, #36]
+ subs h, h, #16
+ add yuv, yuv, dw, lsl #4
+ sub yuv, yuv, w, lsl #1
+ add y, y, yw, lsl #4
+ sub y, y, w
+ add u, u, cw, lsl #3
+ sub u, u, w, asr #1
+ add v, v, cw, lsl #3
+ sub v, v, w, asr #1
+ bgt 1b
+
+ pop {r4-r11,pc}
+ .endfunc
+
--- /tmp/Makefile.am 2010-01-13 09:13:19.000000000 +0100
+++ ticodecplugin/src/Makefile.am 2010-01-13 09:14:38.000000000 +0100
@@ -4,16 +4,16 @@
plugin_LTLIBRARIES = libgstticodecplugin.la
# sources used to compile this plug-in
-libgstticodecplugin_la_SOURCES = gstticodecplugin.c gsttiauddec.c gsttiauddec1.c gsttividdec.c gsttividdec2.c gsttiimgenc1.c gsttiimgenc.c gsttiimgdec1.c gsttiimgdec.c gsttidmaibuffertransport.c gstticircbuffer.c gsttidmaivideosink.c gstticodecs.c gstticodecs_platform.c gsttiquicktime_aac.c gsttiquicktime_h264.c gsttividenc.c gsttividenc1.c gsttiaudenc1.c gstticommonutils.c gsttividresize.c gsttidmaiperf.c gsttiquicktime_mpeg4.c
+libgstticodecplugin_la_SOURCES = gstticodecplugin.c gsttiauddec.c gsttiauddec1.c gsttividdec.c gsttividdec2.c gsttiimgenc1.c gsttiimgenc.c gsttiimgdec1.c gsttiimgdec.c gsttidmaibuffertransport.c gstticircbuffer.c gsttidmaivideosink.c gstticodecs.c gstticodecs_platform.c gsttiquicktime_aac.c gsttiquicktime_h264.c gsttividenc.c gsttividenc1.c gsttiaudenc1.c gstticommonutils.c gsttividresize.c gsttidmaiperf.c gsttiquicktime_mpeg4.c omapfb.c yuv.S
# flags used to compile this plugin
# add other _CFLAGS and _LIBS as needed
-libgstticodecplugin_la_CFLAGS = $(GST_CFLAGS) $(shell cat $(XDC_CONFIG_BASENAME)/compiler.opt)
-libgstticodecplugin_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstvideo-0.10 -lgstaudio-0.10 -lm
+libgstticodecplugin_la_CFLAGS = $(GST_CFLAGS) $(shell cat $(XDC_CONFIG_BASENAME)/compiler.opt) -I$(LINUXKERNEL_INSTALL_DIR)/include
+libgstticodecplugin_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstvideo-0.10 -lgstaudio-0.10 -lm -lX11
libgstticodecplugin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -Wl,$(XDC_CONFIG_BASENAME)/linker.cmd
# headers we need but don't want installed
-noinst_HEADERS = gsttiauddec.h gsttiauddec1.h gsttividdec.h gsttividdec2.h gsttiimgenc1.h gsttiimgenc.h gsttiimgdec1.h gsttiimgdec.h gsttidmaibuffertransport.h gstticircbuffer.h gsttidmaivideosink.h gsttithreadprops.h gstticodecs.h gsttiquicktime_aac.h gsttiquicktime_h264.h gsttividenc.h gsttividenc1.h gsttiaudenc1.h gstticommonutils.h gsttividresize.h gsttiquicktime_mpeg4.h
+noinst_HEADERS = gsttiauddec.h gsttiauddec1.h gsttividdec.h gsttividdec2.h gsttiimgenc1.h gsttiimgenc.h gsttiimgdec1.h gsttiimgdec.h gsttidmaibuffertransport.h gstticircbuffer.h gsttidmaivideosink.h gsttithreadprops.h gstticodecs.h gsttiquicktime_aac.h gsttiquicktime_h264.h gsttividenc.h gsttividenc1.h gsttiaudenc1.h gstticommonutils.h gsttividresize.h gsttiquicktime_mpeg4.h omapfb.h
# XDC Configuration
CONFIGURO = $(XDC_INSTALL_DIR)/xs xdc.tools.configuro
|