annotate avpacket.c @ 9480:d527872fdf26 libavcodec

Remove useless += from ff_imdct_half_c() found by CSA.
author michael
date Fri, 17 Apr 2009 18:12:00 +0000
parents d322325fc00e
children e30999f7a631
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9357
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
1 /*
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
2 * AVPacket functions for libavcodec
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
4 *
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
5 * This file is part of FFmpeg.
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
6 *
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
11 *
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
15 * Lesser General Public License for more details.
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
16 *
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
20 */
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
21
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
22 #include "avcodec.h"
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
23
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
24
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
25 void av_destruct_packet_nofree(AVPacket *pkt)
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
26 {
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
27 pkt->data = NULL; pkt->size = 0;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
28 }
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
29
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
30 void av_destruct_packet(AVPacket *pkt)
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
31 {
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
32 av_free(pkt->data);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
33 pkt->data = NULL; pkt->size = 0;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
34 }
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
35
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
36 void av_init_packet(AVPacket *pkt)
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
37 {
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
38 pkt->pts = AV_NOPTS_VALUE;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
39 pkt->dts = AV_NOPTS_VALUE;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
40 pkt->pos = -1;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
41 pkt->duration = 0;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
42 pkt->convergence_duration = 0;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
43 pkt->flags = 0;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
44 pkt->stream_index = 0;
9394
d322325fc00e Get rid of av_destruct_packet_nofree and use NULL instead.
reimar
parents: 9360
diff changeset
45 pkt->destruct= NULL;
9357
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
46 }
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
47
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
48 int av_new_packet(AVPacket *pkt, int size)
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
49 {
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
50 uint8_t *data;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
51 if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
52 return AVERROR(ENOMEM);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
53 data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
54 if (!data)
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
55 return AVERROR(ENOMEM);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
56 memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
57
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
58 av_init_packet(pkt);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
59 pkt->data = data;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
60 pkt->size = size;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
61 pkt->destruct = av_destruct_packet;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
62 return 0;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
63 }
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
64
9360
66e270967340 Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents: 9357
diff changeset
65 void av_shrink_packet(AVPacket *pkt, int size)
66e270967340 Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents: 9357
diff changeset
66 {
66e270967340 Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents: 9357
diff changeset
67 if (pkt->size <= size) return;
66e270967340 Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents: 9357
diff changeset
68 pkt->size = size;
66e270967340 Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents: 9357
diff changeset
69 memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
66e270967340 Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents: 9357
diff changeset
70 }
66e270967340 Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents: 9357
diff changeset
71
9357
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
72 int av_dup_packet(AVPacket *pkt)
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
73 {
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
74 if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
75 uint8_t *data;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
76 /* We duplicate the packet and don't forget to add the padding again. */
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
77 if((unsigned)pkt->size > (unsigned)pkt->size + FF_INPUT_BUFFER_PADDING_SIZE)
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
78 return AVERROR(ENOMEM);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
79 data = av_malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
80 if (!data) {
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
81 return AVERROR(ENOMEM);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
82 }
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
83 memcpy(data, pkt->data, pkt->size);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
84 memset(data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
85 pkt->data = data;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
86 pkt->destruct = av_destruct_packet;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
87 }
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
88 return 0;
2108342734cc Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff changeset
89 }