QTfrontend/util/libav_iteraction.cpp
author sheepluva
Sun, 28 Oct 2012 20:35:08 +0100
changeset 7860 a90936219ffa
parent 7813 7ac83d79b897
permissions -rw-r--r--
let animation objects delete themselves after they are not being used anymore PS: I don't like that we create new animation objects every single time before a page transition is done, I'm sure that can be done in a nicer way. But at least we're not keeping those non-reused objects around forever now...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7620
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     1
/*
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     2
 * Hedgewars, a free turn based strategy game
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     4
 *
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     8
 *
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    12
 * GNU General Public License for more details.
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    13
 *
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    14
 * You should have received a copy of the GNU General Public License
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    15
 * along with this program; if not, write to the Free Software
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    17
 */
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    18
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    19
#include "libav_iteraction.h"
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    20
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    21
#if VIDEOREC
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    22
extern "C"
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    23
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    24
#include "libavformat/avformat.h"
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    25
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    26
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    27
#include <QVector>
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    28
#include <QList>
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    29
#include <QComboBox>
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    30
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    31
#include "HWApplication.h"
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    32
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    33
struct Codec
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    34
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    35
    CodecID id;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    36
    bool isAudio;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    37
    QString shortName; // used for identification
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    38
    QString longName; // used for displaying to user
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    39
    bool isRecomended;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    40
};
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    41
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    42
struct Format
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    43
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    44
    QString shortName;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    45
    QString longName;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    46
    bool isRecomended;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    47
    QString extension;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    48
    QVector<Codec*> codecs;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    49
};
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    50
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    51
QList<Codec> codecs;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    52
QMap<QString,Format> formats;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    53
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    54
// test if given format supports given codec
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    55
bool FormatQueryCodec(AVOutputFormat *ofmt, enum CodecID codec_id)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    56
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    57
#if LIBAVFORMAT_VERSION_MAJOR >= 54
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    58
    return avformat_query_codec(ofmt, codec_id, FF_COMPLIANCE_NORMAL) == 1;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    59
#else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    60
    if (ofmt->codec_tag)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    61
        return !!av_codec_get_tag(ofmt->codec_tag, codec_id);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    62
    return codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    63
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    64
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    65
7679
bfa26daad684 - Fix some warnings in frontend
unc0rr
parents: 7620
diff changeset
    66
LibavIteraction::LibavIteraction() : QObject()
7620
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    67
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    68
    // initialize libav and register all codecs and formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    69
    av_register_all();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    70
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    71
    // get list of all codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    72
    AVCodec* pCodec = NULL;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    73
    while (pCodec = av_codec_next(pCodec))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    74
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    75
#if LIBAVCODEC_VERSION_MAJOR >= 54
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    76
        if (!av_codec_is_encoder(pCodec))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    77
#else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    78
        if (!pCodec->encode)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    79
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    80
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    81
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    82
        if (pCodec->type != AVMEDIA_TYPE_VIDEO && pCodec->type != AVMEDIA_TYPE_AUDIO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    83
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    84
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    85
        // this encoders seems to be buggy
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    86
        if (strcmp(pCodec->name, "rv10") == 0 || strcmp(pCodec->name, "rv20") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    87
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    88
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    89
        // doesn't support stereo sound
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    90
        if (strcmp(pCodec->name, "real_144") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    91
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    92
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    93
        if (!pCodec->long_name || strlen(pCodec->long_name) == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    94
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    95
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    96
        if (pCodec->type == AVMEDIA_TYPE_VIDEO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    97
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    98
            if (pCodec->supported_framerates != NULL)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    99
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   100
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   101
            // check if codec supports yuv 4:2:0 format
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   102
            if (!pCodec->pix_fmts)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   103
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   104
            bool yuv420Supported = false;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   105
            for (const PixelFormat* pfmt = pCodec->pix_fmts; *pfmt != -1; pfmt++)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   106
                if (*pfmt == PIX_FMT_YUV420P)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   107
                {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   108
                    yuv420Supported = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   109
                    break;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   110
                }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   111
            if (!yuv420Supported)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   112
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   113
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   114
        if (pCodec->type == AVMEDIA_TYPE_AUDIO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   115
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   116
            // check if codec supports signed 16-bit format
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   117
            if (!pCodec->sample_fmts)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   118
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   119
            bool s16Supported = false;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   120
            for (const AVSampleFormat* pfmt = pCodec->sample_fmts; *pfmt != -1; pfmt++)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   121
                if (*pfmt == AV_SAMPLE_FMT_S16)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   122
                {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   123
                    s16Supported = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   124
                    break;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   125
                }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   126
            if (!s16Supported)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   127
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   128
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   129
        // add codec to list of codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   130
        codecs.push_back(Codec());
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   131
        Codec & codec = codecs.back();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   132
        codec.id = pCodec->id;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   133
        codec.isAudio = pCodec->type == AVMEDIA_TYPE_AUDIO;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   134
        codec.shortName = pCodec->name;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   135
        codec.longName = pCodec->long_name;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   136
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   137
        codec.isRecomended = false;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   138
        if (strcmp(pCodec->name, "libx264") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   139
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   140
            codec.longName = "H.264/MPEG-4 Part 10 AVC (x264)";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   141
            codec.isRecomended = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   142
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   143
        else if (strcmp(pCodec->name, "libxvid") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   144
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   145
            codec.longName = "MPEG-4 Part 2 (Xvid)";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   146
            codec.isRecomended = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   147
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   148
        else if (strcmp(pCodec->name, "libmp3lame") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   149
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   150
            codec.longName = "MP3 (MPEG audio layer 3) (LAME)";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   151
            codec.isRecomended = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   152
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   153
        else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   154
            codec.longName = pCodec->long_name;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   155
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   156
        if (strcmp(pCodec->name, "mpeg4") == 0 || strcmp(pCodec->name, "ac3_fixed") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   157
            codec.isRecomended = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   158
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   159
        // FIXME: remove next line
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   160
        //codec.longName += QString(" (%1)").arg(codec.shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   161
    }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   162
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   163
    // get list of all formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   164
    AVOutputFormat* pFormat = NULL;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   165
    while (pFormat = av_oformat_next(pFormat))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   166
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   167
        if (!pFormat->extensions)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   168
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   169
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   170
        // skip some strange formats to not confuse users
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   171
        if (strstr(pFormat->long_name, "raw"))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   172
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   173
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   174
        Format format;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   175
        bool hasVideoCodec = false;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   176
        for (QList<Codec>::iterator codec = codecs.begin(); codec != codecs.end(); ++codec)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   177
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   178
            if (!FormatQueryCodec(pFormat, codec->id))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   179
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   180
            format.codecs.push_back(&*codec);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   181
            if (!codec->isAudio)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   182
                hasVideoCodec = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   183
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   184
        if (!hasVideoCodec)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   185
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   186
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   187
        QString ext(pFormat->extensions);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   188
        ext.truncate(strcspn(pFormat->extensions, ","));
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   189
        format.extension = ext;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   190
        format.shortName = pFormat->name;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   191
        format.longName = QString("%1 (*.%2)").arg(pFormat->long_name).arg(ext);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   192
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   193
        // FIXME: remove next line
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   194
        //format.longName += QString(" (%1)").arg(format.shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   195
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   196
        format.isRecomended = strcmp(pFormat->name, "mp4") == 0 || strcmp(pFormat->name, "avi") == 0;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   197
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   198
        formats[pFormat->name] = format;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   199
    }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   200
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   201
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   202
void LibavIteraction::fillFormats(QComboBox * pFormats)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   203
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   204
    // first insert recomended formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   205
    foreach(const Format & format, formats)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   206
        if (format.isRecomended)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   207
            pFormats->addItem(format.longName, format.shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   208
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   209
    // remember where to place separator between recomended and other formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   210
    int sep = pFormats->count();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   211
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   212
    // insert remaining formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   213
    foreach(const Format & format, formats)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   214
        if (!format.isRecomended)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   215
            pFormats->addItem(format.longName, format.shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   216
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   217
    // insert separator if necessary
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   218
    if (sep != 0 && sep != pFormats->count())
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   219
        pFormats->insertSeparator(sep);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   220
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   221
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   222
void LibavIteraction::fillCodecs(const QString & fmt, QComboBox * pVCodecs, QComboBox * pACodecs)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   223
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   224
    Format & format = formats[fmt];
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   225
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   226
    // first insert recomended codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   227
    foreach(Codec * codec, format.codecs)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   228
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   229
        if (codec->isRecomended)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   230
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   231
            if (codec->isAudio)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   232
                pACodecs->addItem(codec->longName, codec->shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   233
            else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   234
                pVCodecs->addItem(codec->longName, codec->shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   235
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   236
    }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   237
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   238
    // remember where to place separators between recomended and other codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   239
    int vsep = pVCodecs->count();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   240
    int asep = pACodecs->count();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   241
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   242
    // insert remaining codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   243
    foreach(Codec * codec, format.codecs)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   244
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   245
        if (!codec->isRecomended)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   246
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   247
            if (codec->isAudio)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   248
                pACodecs->addItem(codec->longName, codec->shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   249
            else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   250
                pVCodecs->addItem(codec->longName, codec->shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   251
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   252
    }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   253
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   254
    // insert separators if necessary
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   255
    if (vsep != 0 && vsep != pVCodecs->count())
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   256
        pVCodecs->insertSeparator(vsep);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   257
    if (asep != 0 && asep != pACodecs->count())
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   258
        pACodecs->insertSeparator(asep);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   259
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   260
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   261
QString LibavIteraction::getExtension(const QString & format)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   262
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   263
    return formats[format].extension;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   264
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   265
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   266
// get information abaout file (duration, resolution etc) in multiline string
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   267
QString LibavIteraction::getFileInfo(const QString & filepath)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   268
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   269
    AVFormatContext* pContext = NULL;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   270
    QByteArray utf8path = filepath.toUtf8();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   271
    if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   272
        return "";
7813
7ac83d79b897 support video recording on windows with automation and headers
koda
parents: 7794
diff changeset
   273
#if LIBAVFORMAT_VERSION_MAJOR < 54
7620
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   274
    if (av_find_stream_info(pContext) < 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   275
#else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   276
    if (avformat_find_stream_info(pContext, NULL) < 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   277
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   278
        return "";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   279
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   280
    int s = float(pContext->duration)/AV_TIME_BASE;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   281
    QString desc = QString(tr("Duration: %1m %2s\n")).arg(s/60).arg(s%60);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   282
    for (int i = 0; i < (int)pContext->nb_streams; i++)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   283
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   284
        AVStream* pStream = pContext->streams[i];
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   285
        if (!pStream)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   286
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   287
        AVCodecContext* pCodec = pContext->streams[i]->codec;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   288
        if (!pCodec)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   289
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   290
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   291
        if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   292
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   293
            desc += QString(tr("Video: %1x%2, ")).arg(pCodec->width).arg(pCodec->height);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   294
            if (pStream->avg_frame_rate.den)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   295
            {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   296
                float fps = float(pStream->avg_frame_rate.num)/pStream->avg_frame_rate.den;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   297
                desc += QString(tr("%1 fps, ")).arg(fps, 0, 'f', 2);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   298
            }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   299
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   300
        else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   301
            desc += tr("Audio: ");
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   302
        else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   303
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   304
        AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   305
        desc += pDecoder? pDecoder->name : "unknown";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   306
        desc += "\n";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   307
    }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   308
    AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   309
    if (pComment)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   310
        desc += QString("\n") + pComment->value;
7813
7ac83d79b897 support video recording on windows with automation and headers
koda
parents: 7794
diff changeset
   311
#if LIBAVFORMAT_VERSION_MAJOR < 54
7620
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   312
    av_close_input_file(pContext);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   313
#else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   314
    avformat_close_input(&pContext);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   315
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   316
    return desc;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   317
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   318
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   319
#else
7679
bfa26daad684 - Fix some warnings in frontend
unc0rr
parents: 7620
diff changeset
   320
LibavIteraction::LibavIteraction() : QObject()
7620
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   321
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   322
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   323
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   324
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   325
void LibavIteraction::fillFormats(QComboBox * pFormats)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   326
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   327
    Q_UNUSED(pFormats);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   328
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   329
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   330
void LibavIteraction::fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   331
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   332
    Q_UNUSED(format);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   333
    Q_UNUSED(pVCodecs);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   334
    Q_UNUSED(pACodecs);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   335
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   336
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   337
QString LibavIteraction::getExtension(const QString & format)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   338
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   339
    Q_UNUSED(format);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   340
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   341
    return QString();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   342
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   343
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   344
QString LibavIteraction::getFileInfo(const QString & filepath)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   345
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   346
    Q_UNUSED(filepath);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   347
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   348
    return QString();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   349
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   350
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   351
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   352
LibavIteraction & LibavIteraction::instance()
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   353
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   354
    static LibavIteraction instance;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   355
    return instance;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   356
}