1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18 #include "oscl_mem.h"
19 #include "pv_gau.h"
20
21
GAU()22 OSCL_EXPORT_REF GAU::GAU()
23 : free_buffer_states_when_done(false)
24 {
25 oscl_memset(this, 0, sizeof(*this));
26 buf.num_fragments = 0;
27 numMediaSamples = 0;
28 };
29
GAU(GAU & gauElement)30 OSCL_EXPORT_REF GAU::GAU(GAU & gauElement)
31 : free_buffer_states_when_done(false)
32 {
33 // initializing to zero because code may read beyond numMediaSamples.
34 oscl_memset(this, 0, sizeof(*this));
35 numMediaSamples = gauElement.numMediaSamples;
36 for (uint32 ii = 0; ii < numMediaSamples; ii++)
37 {
38 info[ii] = gauElement.info[ii];
39 }
40 buf = gauElement.buf;
41 for (int32 jj = 0; jj < gauElement.buf.num_fragments; jj++)
42 {
43 buf.buf_states[jj]->increment_refcnt();
44 }
45 }
46
~GAU()47 OSCL_EXPORT_REF GAU::~GAU()
48 {
49 for (int32 ii = 0; ii < buf.num_fragments; ii++)
50 {
51 if (buf.buf_states[ii] != NULL)
52 {
53 buf.buf_states[ii]->decrement_refcnt();
54 if (free_buffer_states_when_done && buf.buf_states[ii]->get_refcount() == 0)
55 {
56 OSCL_DELETE(buf.buf_states[ii]);
57 buf.buf_states[ii] = NULL;
58 }
59 }
60 }
61 }
62
getSamplesTotalSize(uint32 number,MediaMetaInfo * metaInfo)63 OSCL_EXPORT_REF uint32 GAU::getSamplesTotalSize(uint32 number, MediaMetaInfo *metaInfo) //return the sum of total sample size
64 {
65 uint32 i, size = 0;
66 for (i = 0; i < number; i++)
67 {
68 size += metaInfo->len;
69 metaInfo++;
70 }
71
72 return size;
73 }
74
75