Menu

FOBS 0.4.2 : remove annoying warnings

user
2008-08-15
2013-05-09
  • Lieven de Cock

    Lieven de Cock - 2008-08-15

    Here are some suggestions to get rid of several warnings :

    1) encoder.cpp --> const char*

    ReturnCode Encoder::chooseCodec(char *name, int type)

    to

    ReturnCode Encoder::chooseCodec(const char *name, int type)

    ----

    ReturnCode Encoder::chooseVideoCodec(char *name)

    to

    ReturnCode Encoder::chooseVideoCodec(const char *name)

    ---

    ReturnCode Encoder::chooseFormat(char *name)

    to

    ReturnCode Encoder::chooseFormat(const char *name)

    2) Encoder.h
       ReturnCode chooseCodec(char *name, int type);
       ReturnCode chooseVideoCodec(char *name);
       ReturnCode chooseAudioCodec(char *name);
       ReturnCode chooseFormat(char *name);

    to

       ReturnCode chooseCodec(const char *name, int type);
       ReturnCode chooseVideoCodec(const char *name);
       ReturnCode chooseAudioCodec(const char *name);
       ReturnCode chooseFormat(const char *name);

    3) Error.cpp

    char *errorMessageArray[]={

    to

    const char *errorMessageArray[]={

    -----

    char *getErrorMessage(ReturnCode error)

    to

    const char *getErrorMessage(ReturnCode error)

    ------

    void log(LogLevel level, char *pattern, ...)

    to

    void log(LogLevel level, const char *pattern, ...)

    ----

    remove the unused variable/line :  (or comment out, since canbe used in outcommented code, same applies for other such fixes)
        static unsigned counter = 0;
    in addAudioFrame(...)

    ----------
    remove the unused variable/line :
        static unsigned counter = 0;
    in addRawFrame(...)

    -----

    remove the unused variable/line :
        static unsigned counter = 0;
    in addPacket(...)

    ------------ BUG ?????????????????
    return something in :
    ReturnCode Encoder::addPacket(AVPacket *pkt)
    {
        //printf("Output packet size=%d pts=%lu dts=%lu counter=%d\n",pkt->size,(long)pkt->pts,(long)pkt->dts, ++counter);
        av_interleaved_write_frame(outputFile, pkt);
    }

    -------

    apply a correct cast on :
    enc->coded_frame->pts != AV_NOPTS_VALUE
    in addRawFrame()  --> now signed/unsigned comparison

    4) Error.h

    char *getErrorMessage(ReturnCode error);

    to

    const char *getErrorMessage(ReturnCode error);

    ---

    void log(LogLevel level, char *pattern, ...);

    to

    void log(LogLevel level, const char *pattern, ...);

    -----

    typedef enum encoding_mode_t{

    to

    enum encoding_mode_t{

    5) PacketBuffer.cpp
    --> add empty line at the end (standard requires an empty line at the end)

    6) PacketBuffer.h
    --> add empty line at the end (standard requires an empty line at the end)

    7) common.h
    --> add empty line at the end (standard requires an empty line at the end)

    8) Decoder.cpp

    remove the unused variable/line :
        const char *codec_string = encoder ? "encoder" : "decoder";
    in find_codec(...)

    ------

          for(int i=0; i < inputFile->nb_streams; i++)

    to

          for(int i=0; i < static_cast<int>(inputFile->nb_streams); ++i)
    in _Open()

    ----
    remove the unused variable/line :
       static unsigned counter = 0;
    in readNextFrame()

    ---

    remove the unused variable/line :
                   AVStream *s = (inputFile->streams[videoStreamIndex]);
    in placeAtNextFrame()

    ----

    remove the unused variable/line :
                int aDen = aTimeBase.den;
    in placeAtNextFrame()

    --- (BUG ??????????????????????????)
    add the return 0 line as below :
    AVCodecContext *Decoder::getVideoCodec()
    {
      if(videoStreamIndex >= 0) return inputFile->streams[videoStreamIndex]->codec;
      return 0;
    }
    ---> similar to getAudioCodec()

    ------ BUG ?????????????????????
    add something to return in case the if statement fails :
    ReturnCode Decoder::setPosition(TimeStamp milliseconds)
    {
        if(isVideoPresent())
        {
            return setFrameByTime(milliseconds);
        }
       // <<<<--------------------------------------------------------- return something here
    }

    ---------- BUG ????????????????
    add something to return in case the if statements fail :
    TimeStamp Decoder::getAVPosition()
    {
        if(isVideoPresent())
        {
            return position;
        }
        if(isAudioPresent())
        {
            return positionAudio;
        }
       // <<<<--------------------------------------------------------- return something here
    }

    9) transcoder.cpp
    apply appropriate cast to :
                if(pkt->pts != AV_NOPTS_VALUE) {
    in transcode() : now signed/unsigned comparison

    -------

    apply appropriate cast to :
                    if (pkt->dts == AV_NOPTS_VALUE)
    in transcode() : now signed/unsigned comparison

    -------

    apply appropriate cast to :
                if(pkt->pts != AV_NOPTS_VALUE) {
    in transcode() : now signed/unsigned comparison

    -------

    apply appropriate cast to :
                    if (pkt->dts == AV_NOPTS_VALUE)
    in transcode() : now signed/unsigned comparison

    ----------- BUG ???????????????
    return something at the end of transcode()
        completion = p;

      }
      // <<--------------------------------------- return something here
    }

    I hope you can integrate these changes/suggestion in your code. Most of them are very straight forward, the ones about the missing return statements can be a bit more difficult, that's why I didn't put a suggestion on *what* to return since I don't know all the exact audio/video stuff ;-)

    kind regards,
    Lieven

     
    • Lieven de Cock

      Lieven de Cock - 2008-08-15

      I'd like to add 1 more :

      Decoder.h

         ~Decoder();

      to

         virtual ~Decoder();

      class with virtual methods is best to have a virtual destructor.

       
      • Jose San Pedro

        Jose San Pedro - 2008-08-15

        Hey,

        thanks a lot for all the feedback. I simply forgot to include that change (hopefully is the only one). I'm keeping track of so many things nowadays :/ My apologies for this. I'll include all of these changes to the main trunk as soon as possible.

        Cheers,

        Jose San Pedro

        PS: Shit, who made days only 24 hours long?!?

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.