QTfrontend/util/libav_iteraction.cpp
author koda
Tue, 23 Oct 2012 06:50:19 +0200
changeset 7794 ab7b94c03bc9
parent 7679 bfa26daad684
child 7813 7ac83d79b897
permissions -rw-r--r--
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
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
#define __STDC_CONSTANT_MACROS
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    23
extern "C"
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    24
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    25
#include "libavformat/avformat.h"
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    28
#include <QVector>
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    29
#include <QList>
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    30
#include <QComboBox>
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    31
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    32
#include "HWApplication.h"
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    33
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    34
struct Codec
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    35
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    36
    CodecID id;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    37
    bool isAudio;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    38
    QString shortName; // used for identification
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    39
    QString longName; // used for displaying to user
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    40
    bool isRecomended;
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    43
struct Format
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    44
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    45
    QString shortName;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    46
    QString longName;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    47
    bool isRecomended;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    48
    QString extension;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    49
    QVector<Codec*> codecs;
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    52
QList<Codec> codecs;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    53
QMap<QString,Format> formats;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    54
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    55
// test if given format supports given codec
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    56
bool FormatQueryCodec(AVOutputFormat *ofmt, enum CodecID codec_id)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    57
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    58
#if LIBAVFORMAT_VERSION_MAJOR >= 54
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    59
    return avformat_query_codec(ofmt, codec_id, FF_COMPLIANCE_NORMAL) == 1;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    60
#else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    61
    if (ofmt->codec_tag)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    62
        return !!av_codec_get_tag(ofmt->codec_tag, codec_id);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    63
    return codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    64
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    65
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    66
7679
bfa26daad684 - Fix some warnings in frontend
unc0rr
parents: 7620
diff changeset
    67
LibavIteraction::LibavIteraction() : QObject()
7620
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    68
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    69
    // initialize libav and register all codecs and formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    70
    av_register_all();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    71
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    72
    // get list of all codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    73
    AVCodec* pCodec = NULL;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    74
    while (pCodec = av_codec_next(pCodec))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    75
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    76
#if LIBAVCODEC_VERSION_MAJOR >= 54
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    77
        if (!av_codec_is_encoder(pCodec))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    78
#else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    79
        if (!pCodec->encode)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    80
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    81
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    82
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    83
        if (pCodec->type != AVMEDIA_TYPE_VIDEO && pCodec->type != AVMEDIA_TYPE_AUDIO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    84
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    85
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    86
        // this encoders seems to be buggy
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    87
        if (strcmp(pCodec->name, "rv10") == 0 || strcmp(pCodec->name, "rv20") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    88
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    89
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    90
        // doesn't support stereo sound
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    91
        if (strcmp(pCodec->name, "real_144") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    92
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    93
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    94
        if (!pCodec->long_name || strlen(pCodec->long_name) == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    95
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    96
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    97
        if (pCodec->type == AVMEDIA_TYPE_VIDEO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    98
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
    99
            if (pCodec->supported_framerates != NULL)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   100
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   101
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   102
            // check if codec supports yuv 4:2:0 format
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   103
            if (!pCodec->pix_fmts)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   104
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   105
            bool yuv420Supported = false;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   106
            for (const PixelFormat* pfmt = pCodec->pix_fmts; *pfmt != -1; pfmt++)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   107
                if (*pfmt == PIX_FMT_YUV420P)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   108
                {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   109
                    yuv420Supported = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   110
                    break;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   111
                }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   112
            if (!yuv420Supported)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   113
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   114
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   115
        if (pCodec->type == AVMEDIA_TYPE_AUDIO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   116
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   117
            // check if codec supports signed 16-bit format
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   118
            if (!pCodec->sample_fmts)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   119
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   120
            bool s16Supported = false;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   121
            for (const AVSampleFormat* pfmt = pCodec->sample_fmts; *pfmt != -1; pfmt++)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   122
                if (*pfmt == AV_SAMPLE_FMT_S16)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   123
                {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   124
                    s16Supported = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   125
                    break;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   126
                }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   127
            if (!s16Supported)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   128
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   129
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   130
        // add codec to list of codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   131
        codecs.push_back(Codec());
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   132
        Codec & codec = codecs.back();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   133
        codec.id = pCodec->id;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   134
        codec.isAudio = pCodec->type == AVMEDIA_TYPE_AUDIO;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   135
        codec.shortName = pCodec->name;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   136
        codec.longName = pCodec->long_name;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   137
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   138
        codec.isRecomended = false;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   139
        if (strcmp(pCodec->name, "libx264") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   140
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   141
            codec.longName = "H.264/MPEG-4 Part 10 AVC (x264)";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   142
            codec.isRecomended = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   143
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   144
        else if (strcmp(pCodec->name, "libxvid") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   145
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   146
            codec.longName = "MPEG-4 Part 2 (Xvid)";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   147
            codec.isRecomended = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   148
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   149
        else if (strcmp(pCodec->name, "libmp3lame") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   150
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   151
            codec.longName = "MP3 (MPEG audio layer 3) (LAME)";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   152
            codec.isRecomended = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   153
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   154
        else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   155
            codec.longName = pCodec->long_name;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   156
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   157
        if (strcmp(pCodec->name, "mpeg4") == 0 || strcmp(pCodec->name, "ac3_fixed") == 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   158
            codec.isRecomended = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   159
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   160
        // FIXME: remove next line
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   161
        //codec.longName += QString(" (%1)").arg(codec.shortName);
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   164
    // get list of all formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   165
    AVOutputFormat* pFormat = NULL;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   166
    while (pFormat = av_oformat_next(pFormat))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   167
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   168
        if (!pFormat->extensions)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   169
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   170
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   171
        // skip some strange formats to not confuse users
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   172
        if (strstr(pFormat->long_name, "raw"))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   173
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   174
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   175
        Format format;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   176
        bool hasVideoCodec = false;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   177
        for (QList<Codec>::iterator codec = codecs.begin(); codec != codecs.end(); ++codec)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   178
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   179
            if (!FormatQueryCodec(pFormat, codec->id))
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   180
                continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   181
            format.codecs.push_back(&*codec);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   182
            if (!codec->isAudio)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   183
                hasVideoCodec = true;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   184
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   185
        if (!hasVideoCodec)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   186
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   187
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   188
        QString ext(pFormat->extensions);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   189
        ext.truncate(strcspn(pFormat->extensions, ","));
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   190
        format.extension = ext;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   191
        format.shortName = pFormat->name;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   192
        format.longName = QString("%1 (*.%2)").arg(pFormat->long_name).arg(ext);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   193
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   194
        // FIXME: remove next line
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   195
        //format.longName += QString(" (%1)").arg(format.shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   196
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   197
        format.isRecomended = strcmp(pFormat->name, "mp4") == 0 || strcmp(pFormat->name, "avi") == 0;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   198
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   199
        formats[pFormat->name] = format;
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   203
void LibavIteraction::fillFormats(QComboBox * pFormats)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   204
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   205
    // first insert recomended formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   206
    foreach(const Format & format, formats)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   207
        if (format.isRecomended)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   208
            pFormats->addItem(format.longName, format.shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   209
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   210
    // remember where to place separator between recomended and other formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   211
    int sep = pFormats->count();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   212
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   213
    // insert remaining formats
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   214
    foreach(const Format & format, formats)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   215
        if (!format.isRecomended)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   216
            pFormats->addItem(format.longName, format.shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   217
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   218
    // insert separator if necessary
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   219
    if (sep != 0 && sep != pFormats->count())
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   220
        pFormats->insertSeparator(sep);
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   223
void LibavIteraction::fillCodecs(const QString & fmt, QComboBox * pVCodecs, QComboBox * pACodecs)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   224
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   225
    Format & format = formats[fmt];
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   226
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   227
    // first insert recomended codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   228
    foreach(Codec * codec, format.codecs)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   229
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   230
        if (codec->isRecomended)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   231
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   232
            if (codec->isAudio)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   233
                pACodecs->addItem(codec->longName, codec->shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   234
            else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   235
                pVCodecs->addItem(codec->longName, codec->shortName);
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   239
    // remember where to place separators between recomended and other codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   240
    int vsep = pVCodecs->count();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   241
    int asep = pACodecs->count();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   242
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   243
    // insert remaining codecs
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   244
    foreach(Codec * codec, format.codecs)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   245
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   246
        if (!codec->isRecomended)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   247
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   248
            if (codec->isAudio)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   249
                pACodecs->addItem(codec->longName, codec->shortName);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   250
            else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   251
                pVCodecs->addItem(codec->longName, codec->shortName);
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   255
    // insert separators if necessary
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   256
    if (vsep != 0 && vsep != pVCodecs->count())
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   257
        pVCodecs->insertSeparator(vsep);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   258
    if (asep != 0 && asep != pACodecs->count())
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   259
        pACodecs->insertSeparator(asep);
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   262
QString LibavIteraction::getExtension(const QString & format)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   263
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   264
    return formats[format].extension;
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   267
// get information abaout file (duration, resolution etc) in multiline string
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   268
QString LibavIteraction::getFileInfo(const QString & filepath)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   269
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   270
    AVFormatContext* pContext = NULL;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   271
    QByteArray utf8path = filepath.toUtf8();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   272
    if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   273
        return "";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   274
#if LIBAFORMAT_VERSION_MAJOR < 54
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   275
    if (av_find_stream_info(pContext) < 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   276
#else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   277
    if (avformat_find_stream_info(pContext, NULL) < 0)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   278
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   279
        return "";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   280
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   281
    int s = float(pContext->duration)/AV_TIME_BASE;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   282
    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
   283
    for (int i = 0; i < (int)pContext->nb_streams; i++)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   284
    {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   285
        AVStream* pStream = pContext->streams[i];
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   286
        if (!pStream)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   287
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   288
        AVCodecContext* pCodec = pContext->streams[i]->codec;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   289
        if (!pCodec)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   290
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   291
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   292
        if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   293
        {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   294
            desc += QString(tr("Video: %1x%2, ")).arg(pCodec->width).arg(pCodec->height);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   295
            if (pStream->avg_frame_rate.den)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   296
            {
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   297
                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
   298
                desc += QString(tr("%1 fps, ")).arg(fps, 0, 'f', 2);
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
        }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   301
        else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   302
            desc += tr("Audio: ");
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   303
        else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   304
            continue;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   305
        AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   306
        desc += pDecoder? pDecoder->name : "unknown";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   307
        desc += "\n";
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   308
    }
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   309
    AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   310
    if (pComment)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   311
        desc += QString("\n") + pComment->value;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   312
#if LIBAFORMAT_VERSION_MAJOR < 54
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   313
    av_close_input_file(pContext);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   314
#else
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   315
    avformat_close_input(&pContext);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   316
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   317
    return desc;
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   320
#else
7679
bfa26daad684 - Fix some warnings in frontend
unc0rr
parents: 7620
diff changeset
   321
LibavIteraction::LibavIteraction() : QObject()
7620
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   326
void LibavIteraction::fillFormats(QComboBox * pFormats)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   327
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   328
    Q_UNUSED(pFormats);
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   331
void LibavIteraction::fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   332
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   333
    Q_UNUSED(format);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   334
    Q_UNUSED(pVCodecs);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   335
    Q_UNUSED(pACodecs);
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   338
QString LibavIteraction::getExtension(const QString & format)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   339
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   340
    Q_UNUSED(format);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   341
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   342
    return QString();
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
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   345
QString LibavIteraction::getFileInfo(const QString & filepath)
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   346
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   347
    Q_UNUSED(filepath);
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   348
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   349
    return QString();
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   350
}
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   351
#endif
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   352
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   353
LibavIteraction & LibavIteraction::instance()
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   354
{
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   355
    static LibavIteraction instance;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   356
    return instance;
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   357
}