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