~ubuntu-branches/ubuntu/trusty/libav/trusty

« back to all changes in this revision

Viewing changes to libavcodec/libschroedingerenc.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-19 15:04:55 UTC
  • mfrom: (1.2.1 upstream)
  • mto: (1.3.4 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20110419150455-c1nac6gjm3t2aa4n
Tags: 4:0.7~b1-1
* New upstream version
* bump SONAME and SHLIBS
* configure flags --disable-stripping was removed upstream
* the MAINTAINERS file was removed upstream
* remove patch disable-configuration-warning.patch
* drop avfilter confflags, it is enable by default in 0.7
* libfaad wrapper has been removed upstream
* also update the *contents* of the lintian overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Dirac encoder support via Schroedinger libraries
3
3
 * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com >
4
4
 *
5
 
 * This file is part of FFmpeg.
 
5
 * This file is part of Libav.
6
6
 *
7
 
 * FFmpeg is free software; you can redistribute it and/or
 
7
 * Libav is free software; you can redistribute it and/or
8
8
 * modify it under the terms of the GNU Lesser General Public
9
9
 * License as published by the Free Software Foundation; either
10
10
 * version 2.1 of the License, or (at your option) any later version.
11
11
 *
12
 
 * FFmpeg is distributed in the hope that it will be useful,
 
12
 * Libav is distributed in the hope that it will be useful,
13
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
15
 * Lesser General Public License for more details.
16
16
 *
17
17
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with FFmpeg; if not, write to the Free Software
 
18
 * License along with Libav; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
21
21
 
37
37
#include "avcodec.h"
38
38
#include "libdirac_libschro.h"
39
39
#include "libschroedinger.h"
 
40
#include "bytestream.h"
40
41
 
41
42
 
42
43
/** libschroedinger encoder private data */
127
128
    if (SetSchroChromaFormat(avccontext) == -1)
128
129
        return -1;
129
130
 
 
131
    if (avccontext->color_primaries == AVCOL_PRI_BT709) {
 
132
        p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_HDTV;
 
133
    } else if (avccontext->color_primaries == AVCOL_PRI_BT470BG) {
 
134
        p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_625;
 
135
    } else if (avccontext->color_primaries == AVCOL_PRI_SMPTE170M) {
 
136
        p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_525;
 
137
    }
 
138
 
 
139
    if (avccontext->colorspace == AVCOL_SPC_BT709) {
 
140
        p_schro_params->format->colour_matrix = SCHRO_COLOUR_MATRIX_HDTV;
 
141
    } else if (avccontext->colorspace == AVCOL_SPC_BT470BG) {
 
142
        p_schro_params->format->colour_matrix = SCHRO_COLOUR_MATRIX_SDTV;
 
143
    }
 
144
 
 
145
    if (avccontext->color_trc == AVCOL_TRC_BT709) {
 
146
        p_schro_params->format->transfer_function = SCHRO_TRANSFER_CHAR_TV_GAMMA;
 
147
    }
 
148
 
130
149
    if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,
131
150
                                  &p_schro_params->frame_format) == -1) {
132
151
        av_log(avccontext, AV_LOG_ERROR,
154
173
                                             "enable_noarith", 1);
155
174
    } else {
156
175
        schro_encoder_setting_set_double(p_schro_params->encoder,
157
 
                                         "gop_structure",
158
 
                                         SCHRO_ENCODER_GOP_BIREF);
 
176
                                         "au_distance", avccontext->gop_size);
159
177
        avccontext->has_b_frames = 1;
160
178
    }
161
179
 
167
185
                                             "rate_control",
168
186
                                             SCHRO_ENCODER_RATE_CONTROL_LOSSLESS);
169
187
        } else {
170
 
            int noise_threshold;
 
188
            int quality;
171
189
            schro_encoder_setting_set_double(p_schro_params->encoder,
172
190
                                             "rate_control",
173
 
                                             SCHRO_ENCODER_RATE_CONTROL_CONSTANT_NOISE_THRESHOLD);
 
191
                                             SCHRO_ENCODER_RATE_CONTROL_CONSTANT_QUALITY);
174
192
 
175
 
            noise_threshold = avccontext->global_quality / FF_QP2LAMBDA;
176
 
            if (noise_threshold > 100)
177
 
                noise_threshold = 100;
 
193
            quality = avccontext->global_quality / FF_QP2LAMBDA;
 
194
            if (quality > 10)
 
195
                quality = 10;
178
196
            schro_encoder_setting_set_double(p_schro_params->encoder,
179
 
                                             "noise_threshold",
180
 
                                             noise_threshold);
 
197
                                             "quality", quality);
181
198
        }
182
199
    } else {
183
200
        schro_encoder_setting_set_double(p_schro_params->encoder,
196
213
        schro_encoder_setting_set_double(p_schro_params->encoder,
197
214
                                         "interlaced_coding", 1);
198
215
 
 
216
    schro_encoder_setting_set_double(p_schro_params->encoder, "open_gop",
 
217
                                     !(avccontext->flags & CODEC_FLAG_CLOSED_GOP));
 
218
 
199
219
    /* FIXME: Signal range hardcoded to 8-bit data until both libschroedinger
200
220
     * and libdirac support other bit-depth data. */
201
221
    schro_video_format_set_std_signal_range(p_schro_params->format,
318
338
 
319
339
            /* Parse the coded frame number from the bitstream. Bytes 14
320
340
             * through 17 represesent the frame number. */
321
 
                p_frame_output->frame_num = (enc_buf->data[13] << 24) +
322
 
                                            (enc_buf->data[14] << 16) +
323
 
                                            (enc_buf->data[15] <<  8) +
324
 
                                             enc_buf->data[16];
 
341
            p_frame_output->frame_num = AV_RB32(enc_buf->data + 13);
325
342
 
326
343
            ff_dirac_schro_queue_push_back(&p_schro_params->enc_frame_queue,
327
344
                                           p_frame_output);
405
422
}
406
423
 
407
424
 
408
 
AVCodec libschroedinger_encoder = {
 
425
AVCodec ff_libschroedinger_encoder = {
409
426
    "libschroedinger",
410
427
    AVMEDIA_TYPE_VIDEO,
411
428
    CODEC_ID_DIRAC,