~ubuntu-branches/ubuntu/utopic/ffmpeg-debian/utopic

« back to all changes in this revision

Viewing changes to libavformat/avc.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 09:20:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120092053-izz63p40hc98qfgp
Tags: 3:0.svn20090119-1ubuntu1
* merge from debian. LP: #318501
* new version fixes CVE-2008-3230, LP: #253767

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * License along with FFmpeg; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
 
21
 
 
22
#include "libavutil/intreadwrite.h"
21
23
#include "avformat.h"
22
24
#include "avio.h"
23
25
 
58
60
    return end + 3;
59
61
}
60
62
 
61
 
int ff_avc_parse_nal_units(const uint8_t *buf_in, uint8_t **buf, int *size)
 
63
int ff_avc_parse_nal_units(ByteIOContext *pb, const uint8_t *buf_in, int size)
62
64
{
63
 
    ByteIOContext *pb;
64
65
    const uint8_t *p = buf_in;
65
 
    const uint8_t *end = p + *size;
 
66
    const uint8_t *end = p + size;
66
67
    const uint8_t *nal_start, *nal_end;
67
 
    int ret = url_open_dyn_buf(&pb);
68
 
    if(ret < 0)
69
 
        return ret;
70
68
 
 
69
    size = 0;
71
70
    nal_start = ff_avc_find_startcode(p, end);
72
71
    while (nal_start < end) {
73
72
        while(!*(nal_start++));
74
73
        nal_end = ff_avc_find_startcode(nal_start, end);
75
74
        put_be32(pb, nal_end - nal_start);
76
75
        put_buffer(pb, nal_start, nal_end - nal_start);
 
76
        size += 4 + nal_end - nal_start;
77
77
        nal_start = nal_end;
78
78
    }
 
79
    return size;
 
80
}
 
81
 
 
82
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
 
83
{
 
84
    ByteIOContext *pb;
 
85
    int ret = url_open_dyn_buf(&pb);
 
86
    if(ret < 0)
 
87
        return ret;
 
88
 
 
89
    ff_avc_parse_nal_units(pb, buf_in, *size);
 
90
 
79
91
    av_freep(buf);
80
92
    *size = url_close_dyn_buf(pb, buf);
81
93
    return 0;
85
97
{
86
98
    if (len > 6) {
87
99
        /* check for h264 start code */
88
 
        if (AV_RB32(data) == 0x00000001) {
 
100
        if (AV_RB32(data) == 0x00000001 ||
 
101
            AV_RB24(data) == 0x000001) {
89
102
            uint8_t *buf=NULL, *end, *start;
90
103
            uint32_t sps_size=0, pps_size=0;
91
104
            uint8_t *sps=0, *pps=0;
92
105
 
93
 
            int ret = ff_avc_parse_nal_units(data, &buf, &len);
 
106
            int ret = ff_avc_parse_nal_units_buf(data, &buf, &len);
94
107
            if (ret < 0)
95
108
                return ret;
96
109
            start = buf;