Contents of /trunk/mjpegtools/patches/mjpegtools-1.8.0-lavrec-memleak.patch
Parent Directory | Revision Log
Revision 224 -
(show annotations)
(download)
Sat Jun 23 13:53:28 2007 UTC (17 years, 3 months ago) by niro
File size: 2473 byte(s)
Sat Jun 23 13:53:28 2007 UTC (17 years, 3 months ago) by niro
File size: 2473 byte(s)
-new fixes
1 | --- mjpegtools-1.8.0/lavtools/lav_io.c 2005-08-27 13:47:20.000000000 +0200 |
2 | +++ mjpegtools-1.8.0___fixed/lavtools/lav_io.c 2006-05-14 05:45:48.000000000 +0200 |
3 | @@ -540,15 +540,12 @@ |
4 | |
5 | int lav_write_audio(lav_file_t *lav_file, uint8_t *buff, long samps) |
6 | { |
7 | - int res; |
8 | + int res = -1; |
9 | #ifdef HAVE_LIBQUICKTIME |
10 | int i, j; |
11 | - int16_t *qt_audio = (int16_t *)buff, **qt_audion; |
12 | + int16_t *buff16 = (int16_t *)buff, **qt_audion; |
13 | int channels = lav_audio_channels(lav_file); |
14 | - |
15 | - qt_audion = malloc(channels * sizeof (int16_t **)); |
16 | - for (i = 0; i < channels; i++) |
17 | - qt_audion[i] = (int16_t *)malloc(samps * lav_file->bps); |
18 | + int bits = lav_audio_bits(lav_file); |
19 | #endif |
20 | |
21 | video_format = lav_file->format; internal_error = 0; /* for error messages */ |
22 | @@ -557,24 +554,43 @@ |
23 | { |
24 | case 'a': |
25 | case 'A': |
26 | - res = AVI_write_audio( lav_file->avi_fd, buff, samps*lav_file->bps); |
27 | + res = AVI_write_audio(lav_file->avi_fd, buff, samps*lav_file->bps); |
28 | break; |
29 | #ifdef HAVE_LIBQUICKTIME |
30 | case 'q': |
31 | - /* Deinterleave the audio into the two channels. */ |
32 | - for (i = 0; i < samps; i++) |
33 | - { |
34 | - for (j = 0; j < channels; j++) |
35 | - qt_audion[j][i] = qt_audio[(channels*i) + j]; |
36 | - } |
37 | - res = lqt_encode_audio_track(lav_file->qt_fd, qt_audion, NULL,samps,0); |
38 | - for (j = 0; j < channels; j++) |
39 | - free(qt_audion[j]); |
40 | - free(qt_audion); |
41 | - break; |
42 | + if (bits != 16 || channels > 1) |
43 | + { |
44 | + /* Deinterleave the audio into the two channels and/or convert |
45 | + * bits per sample to the required format. |
46 | + */ |
47 | + qt_audion = malloc(channels * sizeof(*qt_audion)); |
48 | + for (i = 0; i < channels; i++) |
49 | + qt_audion[i] = malloc(samps * sizeof(**qt_audion)); |
50 | + |
51 | + if (bits == 16) |
52 | + for (i = 0; i < samps; i++) |
53 | + for (j = 0; j < channels; j++) |
54 | + qt_audion[j][i] = buff16[channels * i + j]; |
55 | + else |
56 | + if (bits == 8) |
57 | + for (i = 0; i < samps; i++) |
58 | + for (j = 0; j < channels; j++) |
59 | + qt_audion[j][i] = ((int16_t)(buff[channels * i + j]) << 8) ^ 0x8000; |
60 | + |
61 | + if (bits == 8 || bits == 16) |
62 | + res = lqt_encode_audio_track(lav_file->qt_fd, qt_audion, NULL, samps, 0); |
63 | + |
64 | + for (i = 0; i < channels; i++) |
65 | + free(qt_audion[i]); |
66 | + free(qt_audion); |
67 | + } else { |
68 | + qt_audion = &buff16; |
69 | + res = lqt_encode_audio_track(lav_file->qt_fd, qt_audion, NULL, samps, 0); |
70 | + } |
71 | + break; |
72 | #endif |
73 | default: |
74 | - res = -1; |
75 | + break; |
76 | } |
77 | |
78 | return res; |