Ticket #5932: ResolutionInDB.2.diff

File ResolutionInDB.2.diff, 4.7 KB (added by robert.mcnamara@…, 15 years ago)

This version will work with H.264 as well.

  • libs/libmythtv/recorderbase.cpp

     
    240240
    241241    if (rb_changed)
    242242        m_videoAspect = 0;
     243        m_videoWidth = 0;
     244        m_videoHeight = 0;
    243245}
    244246
    245247/** \fn RecorderBase::SavePositionMap(bool)
     
    302304        curRecording->SetAspectChange(mark, frame);
    303305}
    304306
     307void RecorderBase::ResolutionChange(uint width,uint height)
     308{
     309    if (curRecording)
     310        curRecording->SetResolution(width, height);
     311}
     312
     313
    305314/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • libs/libmythtv/dtvrecorder.cpp

     
    261261    bool hasKeyFrame  = false;
    262262
    263263    uint aspectRatio = 0;
     264    uint height = 0;
     265    uint width = 0;
    264266
    265267    // Scan for PES header codes; specifically picture_start
    266268    // sequence_start (SEQ) and group_start (GOP).
     
    293295
    294296                // Look for aspectRatio changes and store them in the database
    295297                aspectRatio = (bufptr[3] >> 4);
     298
     299                // Get resolution
     300                height = ((bufptr[1] & 0xf) << 8) | bufptr[2];
     301                width = (bufptr[0] <<4) | (bufptr[1]>>4);
     302
    296303                //int frameRate = (bufptr[3] & 0x0000000f);
    297304            }
    298305        }
     
    328335        AspectChange((AspectRatio)aspectRatio, _frames_written_count);
    329336    }
    330337
     338    if ((height > 0) && (height != m_videoHeight))
     339    {
     340        m_videoHeight = height;
     341        ResolutionChange(width, height);
     342    }
     343
    331344    return hasKeyFrame || (_payload_buffer.size() >= (188*50));
    332345}
    333346
     
    469482        _start_code = 0xffffffff;
    470483    }
    471484
     485    uint height = 0;
     486    uint width = 0;
     487
    472488    bool hasFrame = false;
    473489    bool hasKeyFrame = false;
    474490
     
    551567                hasFrame = true;
    552568                _seen_sps |= hasKeyFrame;
    553569            }
     570            width = m_h264_parser.pictureWidth();
     571            height  = m_h264_parser.pictureHeight();
    554572        }
    555573    } // for (; i < TSPacket::SIZE; i++)
    556574
     
    567585            _frames_written_count++;
    568586    }
    569587
     588    if ((height > 0) && (height != m_videoHeight))
     589    {
     590        m_videoHeight = height;
     591        ResolutionChange(width, height);
     592    }
     593
    570594    return hasKeyFrame || (_payload_buffer.size() >= (188*50));
    571595}
    572596
  • libs/libmythtv/recorderbase.h

     
    243243     */
    244244    void AspectChange(AspectRatio ratio, long long frame);
    245245
     246    void ResolutionChange(uint width, uint height);
     247
    246248    TVRec         *tvrec;
    247249    RingBuffer    *ringBuffer;
    248250    bool           weMadeBuffer;
     
    259261
    260262    uint           m_videoAspect; // AspectRatio
    261263
     264    uint           m_videoHeight;
     265    uint           m_videoWidth;
     266
    262267    ProgramInfo   *curRecording;
    263268
    264269    // For handling pausing
  • libs/libmythtv/programinfo.h

     
    314314    // Aspect Ratio map
    315315    void SetAspectChange(MarkTypes type, long long frame);
    316316
     317    // Resolution Set
     318    void SetResolution(uint width, uint height);
     319
    317320    // GUI stuff
    318321    void showDetails(void) const;
    319322    void EditRecording(void);
  • libs/libmythtv/programinfo.cpp

     
    29722972        MythDB::DBError("aspect ratio change insert", query);
    29732973}
    29742974
     2975/** \fn ProgramInfo::SetResolution(uint width, uint height)
     2976 *  \brief Store the Resolution in the recorded table
     2977 */
     2978void ProgramInfo::SetResolution(uint width, uint height)
     2979{
     2980    if (isVideo)
     2981        return;
     2982
     2983    MSqlQuery query(MSqlQuery::InitCon());
     2984
     2985    query.prepare("UPDATE recorded SET"
     2986                    " width = :WIDTH,"
     2987                    " height = :HEIGHT WHERE"
     2988                    " chanid = :CHANID AND"
     2989                    " starttime = :STARTTIME;");
     2990    query.bindValue(":CHANID", chanid);
     2991    query.bindValue(":STARTTIME", recstartts);
     2992
     2993    query.bindValue(":WIDTH", width);
     2994    query.bindValue(":HEIGHT", height);
     2995
     2996    if (!query.exec() || !query.isActive())
     2997        MythDB::DBError("Resolution insert", query);
     2998}
     2999
    29753000/** \fn ProgramInfo::ReactivateRecording(void)
    29763001 *  \brief Asks the scheduler to restart this recording if possible.
    29773002 */