Bug Summary

File:build-analysis/../src/plugins/mp4/mp4ff/mp4sample.c
Warning:line 126, column 21
Function call argument is an uninitialized value

Annotated Source Code

1/*
2** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation; either version 2 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18**
19** Any non-GPL usage of this software or parts of this software is strictly
20** forbidden.
21**
22** The "appropriate copyright message" mentioned in section 2c of the GPLv2
23** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
24**
25** Commercial non-GPL licensing of this software is possible.
26** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
27**
28** $Id: mp4sample.c,v 1.20 2007/11/01 12:33:29 menno Exp $
29**/
30
31#include <stdlib.h>
32#include "mp4ffint.h"
33
34
35int32_t mp4ff_chunk_of_sample(const mp4ff_t *f, const int32_t track, const int32_t sample,
36 int32_t *chunk_sample, int32_t *chunk)
37{
38 int32_t total_entries = 0;
39 int32_t chunk2entry;
40 int32_t chunk1, chunk2, chunk1samples, range_samples, total = 0;
41
42 if (f->track[track] == NULL((void*)0))
4
Taking true branch
43 {
44 return -1;
45 }
46
47 total_entries = f->track[track]->stsc_entry_count;
48
49 chunk1 = 1;
50 chunk1samples = 0;
51 chunk2entry = 0;
52
53 do
54 {
55 chunk2 = f->track[track]->stsc_first_chunk[chunk2entry];
56 *chunk = chunk2 - chunk1;
57 range_samples = *chunk * chunk1samples;
58
59 if (sample < total + range_samples) break;
60
61 chunk1samples = f->track[track]->stsc_samples_per_chunk[chunk2entry];
62 chunk1 = chunk2;
63
64 if(chunk2entry < total_entries)
65 {
66 chunk2entry++;
67 total += range_samples;
68 }
69 } while (chunk2entry < total_entries);
70
71 if (chunk1samples)
72 *chunk = (sample - total) / chunk1samples + chunk1;
73 else
74 *chunk = 1;
75
76 *chunk_sample = total + (*chunk - chunk1) * chunk1samples;
77
78 return 0;
79}
80
81int32_t mp4ff_chunk_to_offset(const mp4ff_t *f, const int32_t track, const int32_t chunk)
82{
83 const mp4ff_track_t * p_track = f->track[track];
84
85 if (p_track->stco_entry_count && (chunk > p_track->stco_entry_count))
86 {
87 return p_track->stco_chunk_offset[p_track->stco_entry_count - 1];
88 } else if (p_track->stco_entry_count) {
89 return p_track->stco_chunk_offset[chunk - 1];
90 } else {
91 return 8;
92 }
93
94 return 0;
95}
96
97int32_t mp4ff_sample_range_size(const mp4ff_t *f, const int32_t track,
98 const int32_t chunk_sample, const int32_t sample)
99{
100 int32_t i, total;
101 const mp4ff_track_t * p_track = f->track[track];
102
103 if (p_track->stsz_sample_size)
104 {
105 return (sample - chunk_sample) * p_track->stsz_sample_size;
106 }
107 else
108 {
109 if (sample>=p_track->stsz_sample_count) return 0;//error
110
111 for(i = chunk_sample, total = 0; i < sample; i++)
112 {
113 total += p_track->stsz_table[i];
114 }
115 }
116
117 return total;
118}
119
120int32_t mp4ff_sample_to_offset(const mp4ff_t *f, const int32_t track, const int32_t sample)
121{
122 int32_t chunk, chunk_sample, chunk_offset1, chunk_offset2;
2
'chunk' declared without an initial value
123
124 mp4ff_chunk_of_sample(f, track, sample, &chunk_sample, &chunk);
3
Calling 'mp4ff_chunk_of_sample'
5
Returning from 'mp4ff_chunk_of_sample'
125
126 chunk_offset1 = mp4ff_chunk_to_offset(f, track, chunk);
6
Function call argument is an uninitialized value
127 chunk_offset2 = chunk_offset1 + mp4ff_sample_range_size(f, track, chunk_sample, sample);
128
129 return chunk_offset2;
130}
131
132int32_t mp4ff_audio_frame_size(const mp4ff_t *f, const int32_t track, const int32_t sample)
133{
134 int32_t bytes;
135 const mp4ff_track_t * p_track = f->track[track];
136
137 if (p_track->stsz_sample_size)
138 {
139 bytes = p_track->stsz_sample_size;
140 } else {
141 bytes = p_track->stsz_table[sample];
142 }
143
144 return bytes;
145}
146
147int32_t mp4ff_set_sample_position(mp4ff_t *f, const int32_t track, const int32_t sample)
148{
149 int32_t offset;
150
151 offset = mp4ff_sample_to_offset(f, track, sample);
1
Calling 'mp4ff_sample_to_offset'
152 mp4ff_set_position(f, offset);
153
154 return 0;
155}