Ticket #5755: aspectratio.diff

File aspectratio.diff, 6.4 KB (added by stuartm, 16 years ago)
  • mythtv/libs/libmythtv/recorderbase.cpp

     
    55#include "tv_rec.h"
    66#include "libmythdb/mythverbose.h"
    77#include "RingBuffer.h"
     8#include "recordingprofile.h"
    89#include "programinfo.h"
    9 #include "recordingprofile.h"
    1010#include "util.h"
    1111
    1212#define TVREC_CARDNUM \
     
    2323    : tvrec(rec), ringBuffer(NULL), weMadeBuffer(true), videocodec("rtjpeg"),
    2424      audiodevice("/dev/dsp"), videodevice("/dev/video"), vbidevice("/dev/vbi"),
    2525      vbimode(0), ntsc(true), ntsc_framerate(true), video_frame_rate(29.97),
    26       curRecording(NULL), request_pause(false), paused(false),
     26      m_videoAspect(0), curRecording(NULL), request_pause(false), paused(false),
    2727      nextRingBuffer(NULL), nextRecording(NULL),
    2828      positionMapType(MARK_GOP_BYFRAME), positionMapLock(false)
    2929{
     
    237237
    238238    if (rb_changed && tvrec)
    239239        tvrec->RingBufferChanged(ringBuffer, curRecording);
     240
     241    if (rb_changed)
     242        m_videoAspect = 0;
    240243}
    241244
    242245/** \fn RecorderBase::SavePositionMap(bool)
     
    274277        positionMapLock.unlock();
    275278}
    276279
     280void RecorderBase::AspectChange(AspectRatio aspect, long long frame)
     281{
     282    MarkTypes mark;
     283    switch (aspect)
     284    {
     285        case ASPECT_1_1 :
     286            mark = MARK_ASPECT_1_1;
     287            break;
     288        case ASPECT_4_3 :
     289            mark = MARK_ASPECT_4_3;
     290            break;
     291        case ASPECT_16_9 :
     292            mark = MARK_ASPECT_16_9;
     293            break;
     294        case ASPECT_21_1_1 :
     295            mark = MARK_ASPECT_21_1_1;
     296            break;
     297        default :
     298            mark = MARK_ASPECT_4_3;
     299    }
     300
     301    if (curRecording)
     302        curRecording->SetAspectChange(mark, frame);
     303}
     304
    277305/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • mythtv/libs/libmythtv/recorderbase.h

     
    212212     */
    213213    void SavePositionMap(bool force = false);
    214214
     215    enum AspectRatio {
     216        ASPECT_UNKNOWN       = 0x00,
     217        ASPECT_1_1           = 0x01,
     218        ASPECT_4_3           = 0x02,
     219        ASPECT_16_9          = 0x03,
     220        ASPECT_21_1_1         = 0x04
     221    };
     222
    215223  protected:
    216224    /** \brief Convenience function used to set integer options from a profile.
    217225     *  \sa SetOption(const QString&, int)
     
    231239     */
    232240    void SetPositionMapType(int type) { positionMapType = type; }
    233241
     242    /** \brief Note a change in aspect ratio in the recordedmark table
     243     */
     244    void AspectChange(AspectRatio ratio, long long frame);
     245
    234246    TVRec         *tvrec;
    235247    RingBuffer    *ringBuffer;
    236248    bool           weMadeBuffer;
     
    245257    bool           ntsc_framerate;
    246258    double         video_frame_rate;
    247259
     260    uint           m_videoAspect; // AspectRatio
     261
    248262    ProgramInfo   *curRecording;
    249263
    250264    // For handling pausing
     
    263277    QMutex                     positionMapLock;
    264278    QMap<long long, long long> positionMap;
    265279    QMap<long long, long long> positionMapDelta;
     280
    266281};
    267282
    268283#endif
  • mythtv/libs/libmythtv/dtvrecorder.cpp

     
    261261    bool hasFrame     = false;
    262262    bool hasKeyFrame  = false;
    263263
     264    uint aspectRatio;
     265
    264266    // Scan for PES header codes; specifically picture_start
    265267    // sequence_start (SEQ) and group_start (GOP).
    266268    //   00 00 01 00: picture_start_code
     
    289291            {
    290292                _last_seq_seen  = _frames_seen_count;
    291293                hasKeyFrame    |= (_last_gop_seen + maxKFD)<_frames_seen_count;
     294
     295                // Look for aspectRatio changes and store them in the database
     296                aspectRatio = (bufptr[3] >> 4);
     297                //int frameRate = (bufptr[3] & 0x0000000f);
    292298            }
    293299        }
    294300    }
     
    317323            _frames_written_count++;
    318324    }
    319325
     326    if ((aspectRatio > 0) && (aspectRatio != m_videoAspect))
     327    {
     328        m_videoAspect = aspectRatio;
     329        AspectChange((AspectRatio)aspectRatio, _frames_written_count);
     330    }
     331
    320332    return hasKeyFrame || (_payload_buffer.size() >= (188*50));
    321333}
    322334
  • mythtv/libs/libmythtv/programinfo.cpp

     
    29452945    }
    29462946}
    29472947
     2948/**
     2949 *  \brief Store a change in aspect ratio in the recordedmark table
     2950 */
     2951void ProgramInfo::SetAspectChange(MarkTypes type, long long frame)
     2952{
     2953    if (isVideo)
     2954        return;
     2955
     2956    VERBOSE(VB_IMPORTANT, QString("Set Aspect Change: %1").arg((int)type));
     2957
     2958    MSqlQuery query(MSqlQuery::InitCon());
     2959
     2960    query.prepare("INSERT INTO recordedmarkup"
     2961                    " (chanid, starttime, mark, type)"
     2962                    " VALUES"
     2963                    " ( :CHANID , :STARTTIME , :MARK , :TYPE );");
     2964    query.bindValue(":CHANID", chanid);
     2965    query.bindValue(":STARTTIME", recstartts);
     2966
     2967    query.bindValue(":MARK", frame);
     2968    query.bindValue(":TYPE", type);
     2969
     2970    if (!query.exec() || !query.isActive())
     2971        MythDB::DBError("aspect ratio change insert", query);
     2972}
     2973
    29482974/** \fn ProgramInfo::ReactivateRecording(void)
    29492975 *  \brief Asks the scheduler to restart this recording if possible.
    29502976 */
  • mythtv/libs/libmythtv/programinfo.h

     
    4141    MARK_GOP_START = 6,
    4242    MARK_KEYFRAME = 7,
    4343    MARK_SCENE_CHANGE = 8,
    44     MARK_GOP_BYFRAME = 9
     44    MARK_GOP_BYFRAME = 9,
     45    MARK_ASPECT_1_1 = 10,
     46    MARK_ASPECT_4_3 = 11,
     47    MARK_ASPECT_16_9 = 12,
     48    MARK_ASPECT_21_1_1 = 13
    4549} MarkTypes;
    4650MPUBLIC QString toString(MarkTypes type);
    4751
     
    307311    void SetPositionMapDBReplacement(PMapDBReplacement *pmap)
    308312        { positionMapDBReplacement = pmap; }
    309313
     314    // Aspect Ratio map
     315    void SetAspectChange(MarkTypes type, long long frame);
     316
    310317    // GUI stuff
    311318    void showDetails(void) const;
    312319    void EditRecording(void);