Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data structure/Container choice

I have the following scenario:

  • Data from multiple video files needs to be held in a data structure/collection.
  • A video file can have 1 to many video streams.
  • Each stream has a field and value pair.

For example:

Video1:
  Stream1:
    format mpeg
    bitrate 700kb/s
    resolution 1024x764

  Stream2:
    format mpeg
    bitrate 600kb/s
    resolution 800x600

Video2:
  Stream1:
    format mpeg
    bitrate 700kb/s
    resolution 1024x764

  Stream2:
    format mpeg
    bitrate 600kb/s
    resolution 800x600

This is what I was consider holding the data in:

QVector<QVector<QStringList>>

Where QStringList are the value pairs (format, mpeg).

Inside QVector holds the multiple pairs for the stream.

Outside QVector holds the everything i.e. each entry/index is data for a single video file.

I'm not sure whether this is the best way to hold the data a I guess a collection inside a collection inside a collection is not going to be very efficient.

Any opinions on alternatives?

like image 797
nf313743 Avatar asked Apr 25 '26 03:04

nf313743


2 Answers

Why not write classes as you need?

class Stream
{
    Format format;
    Resolution res;
    Bitrate br;
};

class Video
{
    QVector<Stream> v_stream;
};

class VideoContainer
{
    QVector<Video> v_video;
};
like image 86
Donotalo Avatar answered Apr 26 '26 15:04

Donotalo


QVector required to continuous location of data such as classical C-array. For general purposes recommended QList instead of QVector which also provides fast index-based access but based on pointers.

like image 39
triclosan Avatar answered Apr 26 '26 16:04

triclosan