~noskcaj/ubuntu/saucy/libav/merge0.8.7-1

« back to all changes in this revision

Viewing changes to libavformat/nuv.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:30:00 UTC
  • mfrom: (1.2.8) (1.1.13 experimental)
  • Revision ID: package-import@ubuntu.com-20120112223000-cmfo7w78q13i2fd9
Tags: 4:0.8~beta2-1ubuntu1
* Merge from debian, remaining changes:
  - don't build against libdirac, lame, libopenjpeg, librtmp, 
    x264, and xvid  (all in universe)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
#include "libavutil/intreadwrite.h"
 
23
#include "libavutil/intfloat.h"
23
24
#include "avformat.h"
 
25
#include "internal.h"
24
26
#include "riff.h"
25
27
 
26
28
typedef struct {
45
47
    return 0;
46
48
}
47
49
 
48
 
//! little macro to sanitize packet size
 
50
/// little macro to sanitize packet size
49
51
#define PKTSIZE(s) (s &  0xffffff)
50
52
 
51
53
/**
52
 
 * \brief read until we found all data needed for decoding
53
 
 * \param vst video stream of which to change parameters
54
 
 * \param ast video stream of which to change parameters
55
 
 * \param myth set if this is a MythTVVideo format file
56
 
 * \return 1 if all required codec data was found
 
54
 * @brief read until we found all data needed for decoding
 
55
 * @param vst video stream of which to change parameters
 
56
 * @param ast video stream of which to change parameters
 
57
 * @param myth set if this is a MythTVVideo format file
 
58
 * @return 1 if all required codec data was found
57
59
 */
58
60
static int get_codec_data(AVIOContext *pb, AVStream *vst,
59
61
                          AVStream *ast, int myth) {
138
140
    avio_rl32(pb); // unused, "desiredheight"
139
141
    avio_r8(pb); // 'P' == progressive, 'I' == interlaced
140
142
    avio_skip(pb, 3); // padding
141
 
    aspect = av_int2dbl(avio_rl64(pb));
 
143
    aspect = av_int2double(avio_rl64(pb));
142
144
    if (aspect > 0.9999 && aspect < 1.0001)
143
145
        aspect = 4.0 / 3.0;
144
 
    fps = av_int2dbl(avio_rl64(pb));
 
146
    fps = av_int2double(avio_rl64(pb));
145
147
 
146
148
    // number of packets per stream type, -1 means unknown, e.g. streaming
147
149
    v_packs = avio_rl32(pb);
152
154
 
153
155
    if (v_packs) {
154
156
        ctx->v_id = stream_nr++;
155
 
        vst = av_new_stream(s, ctx->v_id);
 
157
        vst = avformat_new_stream(s, NULL);
156
158
        if (!vst)
157
159
            return AVERROR(ENOMEM);
158
160
        vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
162
164
        vst->codec->bits_per_coded_sample = 10;
163
165
        vst->sample_aspect_ratio = av_d2q(aspect * height / width, 10000);
164
166
        vst->r_frame_rate = av_d2q(fps, 60000);
165
 
        av_set_pts_info(vst, 32, 1, 1000);
 
167
        avpriv_set_pts_info(vst, 32, 1, 1000);
166
168
    } else
167
169
        ctx->v_id = -1;
168
170
 
169
171
    if (a_packs) {
170
172
        ctx->a_id = stream_nr++;
171
 
        ast = av_new_stream(s, ctx->a_id);
 
173
        ast = avformat_new_stream(s, NULL);
172
174
        if (!ast)
173
175
            return AVERROR(ENOMEM);
174
176
        ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
178
180
        ast->codec->bit_rate = 2 * 2 * 44100 * 8;
179
181
        ast->codec->block_align = 2 * 2;
180
182
        ast->codec->bits_per_coded_sample = 16;
181
 
        av_set_pts_info(ast, 32, 1, 1000);
 
183
        avpriv_set_pts_info(ast, 32, 1, 1000);
182
184
    } else
183
185
        ctx->a_id = -1;
184
186
 
258
260
}
259
261
 
260
262
AVInputFormat ff_nuv_demuxer = {
261
 
    "nuv",
262
 
    NULL_IF_CONFIG_SMALL("NuppelVideo format"),
263
 
    sizeof(NUVContext),
264
 
    nuv_probe,
265
 
    nuv_header,
266
 
    nuv_packet,
267
 
    NULL,
268
 
    NULL,
 
263
    .name           = "nuv",
 
264
    .long_name      = NULL_IF_CONFIG_SMALL("NuppelVideo format"),
 
265
    .priv_data_size = sizeof(NUVContext),
 
266
    .read_probe     = nuv_probe,
 
267
    .read_header    = nuv_header,
 
268
    .read_packet    = nuv_packet,
269
269
    .flags = AVFMT_GENERIC_INDEX,
270
270
};