Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 439606
Collapse All | Expand All

(-)OpenSceneGraph-3.0.1.old//CMakeModules/FindFFmpeg.cmake (-8 / +4 lines)
Lines 131-150 Link Here
131
    SET(FFMPEG_FOUND "YES")
131
    SET(FFMPEG_FOUND "YES")
132
132
133
    SET(FFMPEG_INCLUDE_DIRS
133
    SET(FFMPEG_INCLUDE_DIRS
134
        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat
134
        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
135
        ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice
135
        ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}
136
        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec
136
        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
137
        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavutil
137
        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
138
    )
138
    )
139
139
140
    IF (FFMPEG_STDINT_INCLUDE_DIR)
140
    IF (FFMPEG_STDINT_INCLUDE_DIR)
141
        SET(FFMPEG_INCLUDE_DIRS
141
        SET(FFMPEG_INCLUDE_DIRS
142
            ${FFMPEG_INCLUDE_DIRS}
142
            ${FFMPEG_INCLUDE_DIRS}
143
            ${FFMPEG_STDINT_INCLUDE_DIR}
143
            ${FFMPEG_STDINT_INCLUDE_DIR}
144
            ${FFMPEG_STDINT_INCLUDE_DIR}/libavformat
145
            ${FFMPEG_STDINT_INCLUDE_DIR}/libavdevice
146
            ${FFMPEG_STDINT_INCLUDE_DIR}/libavcodec
147
            ${FFMPEG_STDINT_INCLUDE_DIR}/libavutil
148
        )
144
        )
149
    ENDIF()
145
    ENDIF()
150
146
(-)OpenSceneGraph-3.0.1.old//src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp (-1 / +1 lines)
Lines 89-95 Link Here
89
        //    m_context->flags |= CODEC_FLAG_TRUNCATED;
89
        //    m_context->flags |= CODEC_FLAG_TRUNCATED;
90
90
91
        // Open codec
91
        // Open codec
92
        if (avcodec_open(m_context, p_codec) < 0)
92
        if (avcodec_open2(m_context, p_codec, NULL) < 0)
93
            throw std::runtime_error("avcodec_open() failed");
93
            throw std::runtime_error("avcodec_open() failed");
94
    }
94
    }
95
95
(-)OpenSceneGraph-3.0.1.old//src/osgPlugins/ffmpeg/FFmpegDecoder.cpp (-20 / +11 lines)
Lines 64-84 Link Here
64
        
64
        
65
            OSG_NOTICE<<"Attempting to stream "<<filename<<std::endl;
65
            OSG_NOTICE<<"Attempting to stream "<<filename<<std::endl;
66
66
67
            AVFormatParameters formatParams;
68
            memset(&formatParams, 0, sizeof(AVFormatParameters));
69
            AVInputFormat *iformat;
67
            AVInputFormat *iformat;
68
            AVDictionary *options = NULL;
70
69
71
            formatParams.channel = 0;
70
            av_dict_set(&options, "video_size", "320x240", 0);
72
            formatParams.standard = 0;
71
73
#if 1
72
            av_dict_set(&options, "framerate", "1/30", 0);
74
            formatParams.width = 320;
75
            formatParams.height = 240;
76
#else
77
            formatParams.width = 640;
78
            formatParams.height = 480;
79
#endif            
80
            formatParams.time_base.num = 1;
81
            formatParams.time_base.den = 30;
82
73
83
            std::string format = "video4linux2";
74
            std::string format = "video4linux2";
84
            iformat = av_find_input_format(format.c_str());
75
            iformat = av_find_input_format(format.c_str());
Lines 92-98 Link Here
92
                OSG_NOTICE<<"Failed to find input format: "<<format<<std::endl;
83
                OSG_NOTICE<<"Failed to find input format: "<<format<<std::endl;
93
            }
84
            }
94
85
95
            int error = av_open_input_file(&p_format_context, filename.c_str(), iformat, 0, &formatParams);
86
            int error = avformat_open_input(&p_format_context, filename.c_str(), iformat, &options);
96
            if (error != 0)
87
            if (error != 0)
97
            {
88
            {
98
                std::string error_str;
89
                std::string error_str;
Lines 110-130 Link Here
110
                    default: error_str = "Unknown error"; break;
101
                    default: error_str = "Unknown error"; break;
111
                }
102
                }
112
103
113
                throw std::runtime_error("av_open_input_file() failed : " + error_str);
104
                throw std::runtime_error("avformat_open_input() failed : " + error_str);
114
            }
105
            }
115
        }
106
        }
116
        else
107
        else
117
        {
108
        {
118
            AVInputFormat* av_format = (parameters ? parameters->getFormat() : 0);
109
            AVInputFormat* av_format = (parameters ? parameters->getFormat() : 0);
119
            AVFormatParameters* av_params = (parameters ? parameters->getFormatParameter() : 0);
110
            AVDictionary* av_options = (parameters ? parameters->getOptions() : NULL);
120
            if (av_open_input_file(&p_format_context, filename.c_str(), av_format, 0, av_params) !=0 )
111
            if (avformat_open_input(&p_format_context, filename.c_str(), av_format, &av_options) !=0 )
121
                throw std::runtime_error("av_open_input_file() failed");
112
                throw std::runtime_error("av_open_input_file() failed");
122
        }
113
        }
123
        
114
        
124
        m_format_context.reset(p_format_context);
115
        m_format_context.reset(p_format_context);
125
116
126
        // Retrieve stream info
117
        // Retrieve stream info
127
        if (av_find_stream_info(p_format_context) < 0)
118
        if (avformat_find_stream_info(p_format_context, NULL) < 0)
128
            throw std::runtime_error("av_find_stream_info() failed");
119
            throw std::runtime_error("av_find_stream_info() failed");
129
120
130
        m_duration = double(m_format_context->duration) / AV_TIME_BASE;
121
        m_duration = double(m_format_context->duration) / AV_TIME_BASE;
Lines 134-140 Link Here
134
        m_clocks.reset(m_start);
125
        m_clocks.reset(m_start);
135
126
136
        // Dump info to stderr
127
        // Dump info to stderr
137
        dump_format(p_format_context, 0, filename.c_str(), false);
128
        av_dump_format(p_format_context, 0, filename.c_str(), false);
138
129
139
        // Find and open the first video and audio streams (note that audio stream is optional and only opened if possible)
130
        // Find and open the first video and audio streams (note that audio stream is optional and only opened if possible)
140
131
Lines 292-298 Link Here
292
        // Read the next frame packet
283
        // Read the next frame packet
293
        if (av_read_frame(m_format_context.get(), &packet) < 0)
284
        if (av_read_frame(m_format_context.get(), &packet) < 0)
294
        {
285
        {
295
            if (url_ferror(m_format_context->pb) == 0)
286
            if (m_format_context->pb->eof_reached == 0)
296
                end_of_stream = true;
287
                end_of_stream = true;
297
            else
288
            else
298
                throw std::runtime_error("av_read_frame() failed");
289
                throw std::runtime_error("av_read_frame() failed");
(-)OpenSceneGraph-3.0.1.old//src/osgPlugins/ffmpeg/FFmpegDecoder.hpp (-4 / +3 lines)
Lines 46-53 Link Here
46
        {
46
        {
47
            if (_ptr) 
47
            if (_ptr) 
48
            {
48
            {
49
                OSG_NOTICE<<"Calling av_close_input_file("<<_ptr<<")"<<std::endl;
49
                OSG_NOTICE<<"Calling avformat_close_input("<<_ptr<<")"<<std::endl;
50
                av_close_input_file(_ptr);
50
                avformat_close_input(&_ptr);
51
            }
51
            }
52
            _ptr = 0;
52
            _ptr = 0;
53
        }
53
        }
Lines 151-158 Link Here
151
151
152
inline double FFmpegDecoder::creation_time() const
152
inline double FFmpegDecoder::creation_time() const
153
{
153
{
154
   if(m_format_context) return m_format_context->timestamp;
154
    return HUGE_VAL;
155
   else return HUGE_VAL;
156
}
155
}
157
156
158
inline double FFmpegDecoder::duration() const
157
inline double FFmpegDecoder::duration() const
(-)OpenSceneGraph-3.0.1.old//src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp (-3 / +3 lines)
Lines 83-89 Link Here
83
    m_context = stream->codec;
83
    m_context = stream->codec;
84
84
85
    // Trust the video size given at this point
85
    // Trust the video size given at this point
86
    // (avcodec_open seems to sometimes return a 0x0 size)
86
    // (avcodec_open2 seems to sometimes return a 0x0 size)
87
    m_width = m_context->width;
87
    m_width = m_context->width;
88
    m_height = m_context->height;
88
    m_height = m_context->height;
89
    findAspectRatio();
89
    findAspectRatio();
Lines 105-112 Link Here
105
    //    m_context->flags |= CODEC_FLAG_TRUNCATED;
105
    //    m_context->flags |= CODEC_FLAG_TRUNCATED;
106
106
107
    // Open codec
107
    // Open codec
108
    if (avcodec_open(m_context, m_codec) < 0)
108
    if (avcodec_open2(m_context, m_codec, NULL) < 0)
109
        throw std::runtime_error("avcodec_open() failed");
109
        throw std::runtime_error("avcodec_open2() failed");
110
110
111
    // Allocate video frame
111
    // Allocate video frame
112
    m_frame.reset(avcodec_alloc_frame());
112
    m_frame.reset(avcodec_alloc_frame());
(-)OpenSceneGraph-3.0.1.old//src/osgPlugins/ffmpeg/FFmpegParameters.cpp (-32 / +12 lines)
Lines 8-14 Link Here
8
#if LIBAVCODEC_VERSION_MAJOR >= 53
8
#if LIBAVCODEC_VERSION_MAJOR >= 53
9
extern "C"
9
extern "C"
10
{
10
{
11
    #include <parseutils.h>
11
    #include <libavutil/parseutils.h>
12
}
12
}
13
#define av_parse_video_frame_size av_parse_video_size
13
#define av_parse_video_frame_size av_parse_video_size
14
#define av_parse_video_frame_rate av_parse_video_rate
14
#define av_parse_video_frame_rate av_parse_video_rate
Lines 19-25 Link Here
19
19
20
    extern "C"
20
    extern "C"
21
    {
21
    {
22
        #include <pixdesc.h>
22
        #include <libavutil/pixdesc.h>
23
    }
23
    }
24
    
24
    
25
    inline PixelFormat osg_av_get_pix_fmt(const char *name) { return av_get_pix_fmt(name); }
25
    inline PixelFormat osg_av_get_pix_fmt(const char *name) { return av_get_pix_fmt(name); }
Lines 34-47 Link Here
34
34
35
35
36
FFmpegParameters::FFmpegParameters() :
36
FFmpegParameters::FFmpegParameters() :
37
    m_format(0)
37
    m_format(0),
38
{
38
    m_options(NULL)
39
    memset(&m_parameters, 0, sizeof(m_parameters));
39
{}
40
}
41
40
42
41
43
FFmpegParameters::~FFmpegParameters()
42
FFmpegParameters::~FFmpegParameters()
44
{}
43
{
44
    av_dict_free(&m_options);
45
}
45
46
46
47
47
void FFmpegParameters::parse(const std::string& name, const std::string& value)
48
void FFmpegParameters::parse(const std::string& name, const std::string& value)
Lines 59-98 Link Here
59
    }
60
    }
60
    else if (name == "pixel_format")
61
    else if (name == "pixel_format")
61
    {
62
    {
62
        m_parameters.pix_fmt = osg_av_get_pix_fmt(value.c_str());
63
        av_dict_set(&m_options, "pixel_format", value.c_str(), 0);
63
    }
64
    }
64
    else if (name == "frame_size")
65
    else if (name == "frame_size")
65
    {
66
    {
66
        int frame_width = 0, frame_height = 0;
67
        av_dict_set(&m_options, "video_size", value.c_str(), 0);
67
        if (av_parse_video_frame_size(&frame_width, &frame_height, value.c_str()) < 0)
68
        {
69
            OSG_NOTICE<<"Failed to apply frame size: "<<value.c_str()<<std::endl;
70
            return;
71
        }
72
        if ((frame_width % 2) != 0 || (frame_height % 2) != 0)
73
        {
74
            OSG_NOTICE<<"Frame size must be a multiple of 2: "<<frame_width<<"x"<<frame_height<<std::endl;
75
            return;
76
        }
77
        m_parameters.width = frame_width;
78
        m_parameters.height = frame_height;
79
    }
68
    }
80
    else if (name == "frame_rate")
69
    else if (name == "frame_rate")
81
    {
70
    {
82
        AVRational frame_rate;
71
        av_dict_set(&m_options, "framerate", value.c_str(), 0);
83
        if (av_parse_video_frame_rate(&frame_rate, value.c_str()) < 0)
84
        {
85
            OSG_NOTICE<<"Failed to apply frame rate: "<<value.c_str()<<std::endl;
86
            return;
87
        }
88
        m_parameters.time_base.den = frame_rate.num;
89
        m_parameters.time_base.num = frame_rate.den;
90
    }
72
    }
91
    else if (name == "audio_sample_rate")
73
    else if (name == "audio_sample_rate")
92
    {
74
    {
93
        int audio_sample_rate = 44100;
75
        av_dict_set(&m_options, "sample_rate", value.c_str(), 0);
94
        std::stringstream ss(value); ss >> audio_sample_rate;
95
        m_parameters.sample_rate = audio_sample_rate;
96
    }
76
    }
97
}
77
}
98
78
(-)OpenSceneGraph-3.0.1.old//src/osgPlugins/ffmpeg/FFmpegParameters.hpp (-2 / +2 lines)
Lines 21-34 Link Here
21
    bool isFormatAvailable() const { return m_format!=NULL; }
21
    bool isFormatAvailable() const { return m_format!=NULL; }
22
    
22
    
23
    AVInputFormat* getFormat() { return m_format; }
23
    AVInputFormat* getFormat() { return m_format; }
24
    AVFormatParameters* getFormatParameter() { return &m_parameters; }
24
    AVDictionary* getOptions() { return m_options; }
25
    
25
    
26
    void parse(const std::string& name, const std::string& value);
26
    void parse(const std::string& name, const std::string& value);
27
27
28
protected:
28
protected:
29
29
30
    AVInputFormat* m_format;
30
    AVInputFormat* m_format;
31
    AVFormatParameters m_parameters;
31
    AVDictionary* m_options;
32
};
32
};
33
33
34
34

Return to bug 439606