Mercurial > libavcodec.hg
annotate avpacket.c @ 10903:8c8321b94c35 libavcodec
Mark a few functions as noinline, this makes ff_h264_filter_mb() a bit smaller
and 5% faster.
ff_h264_filter_mb_fast() stay the same size as gcc decided not to inline these
functions there in the first place.
author | michael |
---|---|
date | Sat, 16 Jan 2010 17:27:17 +0000 |
parents | f04468776158 |
children |
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 { |
10673
158f0ea08e82
Make sure av_new_packet() initializes the data and destruct pointers.
michael
parents:
9584
diff
changeset
|
50 uint8_t *data= NULL; |
158f0ea08e82
Make sure av_new_packet() initializes the data and destruct pointers.
michael
parents:
9584
diff
changeset
|
51 if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE) |
10674 | 52 data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); |
10673
158f0ea08e82
Make sure av_new_packet() initializes the data and destruct pointers.
michael
parents:
9584
diff
changeset
|
53 if (data){ |
10674 | 54 memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); |
10673
158f0ea08e82
Make sure av_new_packet() initializes the data and destruct pointers.
michael
parents:
9584
diff
changeset
|
55 }else |
158f0ea08e82
Make sure av_new_packet() initializes the data and destruct pointers.
michael
parents:
9584
diff
changeset
|
56 size=0; |
9357
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; |
10673
158f0ea08e82
Make sure av_new_packet() initializes the data and destruct pointers.
michael
parents:
9584
diff
changeset
|
62 if(!data) |
158f0ea08e82
Make sure av_new_packet() initializes the data and destruct pointers.
michael
parents:
9584
diff
changeset
|
63 return AVERROR(ENOMEM); |
9357
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
64 return 0; |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
65 } |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
66 |
9360
66e270967340
Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents:
9357
diff
changeset
|
67 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
|
68 { |
66e270967340
Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents:
9357
diff
changeset
|
69 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
|
70 pkt->size = size; |
66e270967340
Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents:
9357
diff
changeset
|
71 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
|
72 } |
66e270967340
Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
reimar
parents:
9357
diff
changeset
|
73 |
9357
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
74 int av_dup_packet(AVPacket *pkt) |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
75 { |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
76 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
|
77 uint8_t *data; |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
78 /* 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
|
79 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
|
80 return AVERROR(ENOMEM); |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
81 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
|
82 if (!data) { |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
83 return AVERROR(ENOMEM); |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
84 } |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
85 memcpy(data, pkt->data, pkt->size); |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
86 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
|
87 pkt->data = data; |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
88 pkt->destruct = av_destruct_packet; |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
89 } |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
90 return 0; |
2108342734cc
Move av_packet_*() functions from libavformat/ to libavcodec/, where the
rbultje
parents:
diff
changeset
|
91 } |
9584 | 92 |
93 void av_free_packet(AVPacket *pkt) | |
94 { | |
95 if (pkt) { | |
96 if (pkt->destruct) pkt->destruct(pkt); | |
97 pkt->data = NULL; pkt->size = 0; | |
98 } | |
99 } |