forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpeg-tools-1.5b-tempfile-mpeg-encode.patch
87 lines (79 loc) · 2.48 KB
/
mpeg-tools-1.5b-tempfile-mpeg-encode.patch
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
--- mpeg_encode/parallel.c
+++ mpeg_encode/parallel.c
@@ -586,6 +586,8 @@
* SIDE EFFECTS: none
*
*===========================================================================*/
+/* internal hook into the ReadFrame function */
+void _ReadFrame(MpegFrame *frame, char *fileName, FILE *fileHook, char *conversion, boolean addPath);
void
GetRemoteFrame(frame, frameNumber)
MpegFrame *frame;
@@ -615,8 +617,13 @@
if ( frameNumber != -1 ) {
if ( separateConversion ) {
- sprintf(fileName, "/tmp/foobar%d", machineNumber);
- filePtr = fopen(fileName, "wb");
+ int fd;
+ snprintf(fileName, sizeof(fileName), "/tmp/mpeg_encode_foobar%dXXXXXX", machineNumber);
+ fd = mkstemp(fileName);
+ if (fd == -1 || (filePtr = fdopen(fd, "wb")) == NULL) {
+ perror("ERROR: mpeg_encode->GetRemoteFrame");
+ exit(1);
+ }
/* read in stuff, SafeWrite to file, perform local conversion */
do {
@@ -628,10 +635,12 @@
fwrite(smallBuffer, 1, numBytes, filePtr);
} while ( numBytes == 1000 );
fflush(filePtr);
- fclose(filePtr);
+ rewind(filePtr);
/* now do slave conversion */
- ReadFrame(frame, fileName, slaveConversion, FALSE);
+ _ReadFrame(frame, NULL, filePtr, slaveConversion, FALSE);
+ /* _ReadFrame() will close the file pointer for us */
+ /* fclose(filePtr); */
} else {
Frame_AllocYCC(frame);
--- mpeg_encode/readframe.c
+++ mpeg_encode/readframe.c
@@ -227,14 +227,22 @@
* SIDE EFFECTS: none
*
*===========================================================================*/
+void _ReadFrame(MpegFrame *frame, char *fileName, FILE *fileHook, char *conversion, boolean addPath);
+
+void ReadFrame(MpegFrame *frame, char *fileName, char *conversion, boolean addPath)
+{
+ _ReadFrame(frame, fileName, NULL, conversion, addPath);
+}
+
void
-ReadFrame(frame, fileName, conversion, addPath)
+_ReadFrame(frame, fileName, fileHook, conversion, addPath)
MpegFrame *frame;
char *fileName;
+ FILE *fileHook;
char *conversion;
boolean addPath;
{
- FILE *ifp;
+ FILE *ifp = fileHook;
char command[1024];
char fullFileName[1024];
MpegFrame tempFrame;
@@ -274,6 +282,9 @@
}
#endif
+ if (fileHook)
+ goto file_is_already_opened;
+
if ( fileType == ANY_FILE_TYPE ) {
char *convertPtr, *commandPtr, *charPtr;
@@ -325,6 +336,7 @@
exit(1);
}
+file_is_already_opened:
switch(baseFormat) {
case YUV_FILE_TYPE: