Hi guys,
Is there any special method in c++ called get and which doesn't require instantiation?
I'm investigating a c++ code and a found this method ((!h264Decoder.get() || !params.get() || !in.get() || !out.get() || !splitter.get() || (!color && !No_CC_Flag)))
When i tried to find this method, I couldn't find it.

Thank you in advance,

Recommended Answers

All 13 Replies

Thanks.

What does it mean to you something like this:
out.get ( )->class ( ).function ( );

I couldn't understand the meaning of this line

What does it mean to you something like this: out.get ( )->class ( ).function ( );

That's not possible, you can't use the -> operator on an integer value :)

Well, in this code it's possible. I don't know what does it mean exactly? I'm newbie to c++

You said that we can not use -> on integer value. What about void?

Well, in this code it's possible. I don't know what does it mean exactly? I'm newbie to c++

If it's possible then there's probably something between the braces of out.get( ) , can you please post the whole line?

You said that we can not use -> on integer value. What about void?

If you write out.get() it will return an integer value (not a void ), but you cannot use the arrow operator (->) on an integer, it's intended for classes and structures :)

>I'm newbie to c++
Then you should start with the simpler things first, you need to understand the basics of C++ before you proceed on learning to more advanced parts :)

Here's the whole function

int main( Ipp32s argc, vm_char *argv[])
{
    Ipp32s i;
    vm_char SrcFileName[UMC::MAXIMUM_PATH] = VM_STRING("");
    vm_char DstFileName[UMC::MAXIMUM_PATH] = VM_STRING("");

    vm_file   *f_dst = 0;
    Ipp64f encode_time = 0;
    Ipp32s numDecodedFrames = 0;
    Ipp32s No_CC_Flag = 1;
    Ipp32s numFramesToDecode = (1 << 30);

    vm_file *perf_file = 0;

    ColorFormat cf = UMC::NONE;

    ippStaticInit();

    //////////////////////////////////////////////////////////////////////////
    // Loading command line params
    //////////////////////////////////////////////////////////////////////////
    for (i = 1; i < argc; i++)
    {
        size_t stArgLen = vm_string_strlen(argv[i]);
        if ('-' == argv[i][0])
        {
            switch (argv[i][1])
            {
            case 't':
            case 'T':
                if (2 == vm_string_strlen(argv[i])) {
                    i++;
                    if(argv[i][0]=='-') {
                        PrintHelp(argv[0]);
                        return 1;
                    } else {
                        num_threads = (Ipp32s)vm_string_atol(argv[i]);
                    }
                } else {
                    num_threads = (Ipp32s)vm_string_atol(argv[i] + 2);
                }
                break;
            case 'P':
            case 'p':
                i++;
                perf_file = vm_file_open(argv[i], VM_STRING("a"));
                break;
            case 'F':
            case 'f':
                {
                    vm_char* szCode = argv[i];

                    if (0 == vm_string_strcmp(szCode, VM_STRING("-fyv12")))
                    {   cf = UMC::YV12;    }
                    else if (0 == vm_string_strcmp(szCode, VM_STRING("-fyuy2")))
                    {   cf = UMC::YUY2;    }
                    else if (0 == vm_string_strcmp(szCode, VM_STRING("-frgb565")))
                    {   cf = UMC::RGB565; }
                    else if (0 == vm_string_strcmp(szCode, VM_STRING("-frgb24")))
                    {   cf = UMC::RGB24; }
                    else if (0 == vm_string_strcmp(szCode, VM_STRING("-fyuv420")))
                    {   cf = UMC::YUV420; }
                    else if (0 == vm_string_strcmp(szCode, VM_STRING("-fyuv422")))
                    {   cf = UMC::YUV422; }
                    else if (0 == vm_string_strcmp(szCode, VM_STRING("-fyuv444")))
                    {   cf = UMC::YUV444; }
                    else
                    { num_frames = (Ipp32s)vm_string_atol(argv[i] + 2); }
                    break;
                }
                break;
            case 'h':
            case 'H':
            case '?':
            default:
                PrintHelp(argv[0]);
                return 1;
            }
        }
        else
        {
            if (0 == SrcFileName[0]) {
                i = FileNameFromParams(argc, argv, i, SrcFileName);
            } else {
                i = FileNameFromParams(argc, argv, i, DstFileName);
            }
        }
    }

    if (cf != UMC::NONE)
    {
        No_CC_Flag = 0;
    }

    if (SrcFileName[0] == 0)
    {
        PrintHelp(argv[0]);
        return 1;
    }

    if (DstFileName[0] != 0)
    {
        f_dst = vm_file_open(DstFileName, VM_STRING("wb"));
        if (f_dst == NULL)
        {
            vm_string_printf(__VM_STRING("Error opening dst file %s\n"), DstFileName);
            return -1;
        }
    }

    //////////////////////////////////////////////////////////////////////////
    // Initializing
    //////////////////////////////////////////////////////////////////////////
    auto_ptr< H264VideoDecoder > h264Decoder ( new H264VideoDecoder() );
    auto_ptr< VideoDecoderParams > params  ( new VideoDecoderParams() );
    VideoProcessing * color = No_CC_Flag ? 0 : new VideoProcessing();
    auto_ptr<BaseCodec> pPointerCopier (new DataPointersCopy());
    auto_ptr< MediaData > in ( new MediaData() );
    auto_ptr< VideoData > out ( new VideoData() );
    auto_ptr< H264AnnexBSplitter > splitter ( new H264AnnexBSplitter() );

    if(!h264Decoder.get() || !params.get() || !in.get() ||
        !out.get() || !splitter.get() || (!color && !No_CC_Flag))
    {
        vm_string_printf(__VM_STRING("Allocation failed\n"));
        return -1;
    }

    if( UMC_OK != splitter->Init(SrcFileName))
    {
        vm_string_printf(__VM_STRING("Error opening src file %s\n"), SrcFileName);
        return -1;
    }

    bool bEndOfStream = false;
    bool bInitialize = false;

    //////////////////////////////////////////////////////////////////////////
    // Starting the decoding loop
    //////////////////////////////////////////////////////////////////////////

    vm_tick t_start_all = GET_TICKS;

    for (i = 0; i < numFramesToDecode; i++)
    {
        if ((3 > in->GetDataSize()) &&
            (false == bEndOfStream))
        {
            Status statusHelper = splitter->GetNextVideoData(*(in.get()));
            if(UMC_OK != statusHelper){
                bEndOfStream = true;
            }
        }

        if(!bInitialize)
        {
            bInitialize = true;

            if (color)
            {
                VideoProcessingParams postProcessingParams;
                postProcessingParams.m_DeinterlacingMethod = (DeinterlacingMethod)(0 & FLAG_CCNV_DEINTERLACE);;
                postProcessingParams.InterpolationMethod = 0;
                color->SetParams(&postProcessingParams);
            }

            if (color)
                params->pPostProcessing  = color;
            else
                params->pPostProcessing  = pPointerCopier.get();
            params->info.stream_type = H264_VIDEO;
            params->numThreads = num_threads;
            params->lFlags = 0;
            params->m_pData = in.get();

            if (UMC_OK != (h264Decoder->Init(params.get())))
            {
                vm_string_printf(__VM_STRING("Video Decoder creation failed\n"));
                return -1;
            }

            H264VideoDecoderParams params;
            if (UMC_OK != h264Decoder->GetInfo(&params))
            {
                vm_string_printf(__VM_STRING("Video Decoder creation failed\n"));
                return -1;
            }

            out->SetAlignment(16);
            out->Init(params.info.clip_info.width, params.info.clip_info.height, cf, 8);
            out->Alloc();
            continue;
        }

        vm_tick t_start = GET_TICKS;
        Status ret = h264Decoder->GetFrame((bEndOfStream) ? (NULL) : (in.get()), out.get());
        vm_tick t_end = GET_TICKS;
        encode_time += (Ipp64f)(Ipp64s)(t_end-t_start);

        out.get ( )->Meta ( ).dump ( );

        if (UMC_ERR_NOT_ENOUGH_DATA == ret)
        {
            if (bEndOfStream)
                break;
            else
                continue;
        }

        if (UMC_OK != ret)
            continue;

        savedata(f_dst, out.get(), out->GetWidth(), out->GetHeight());
        if (numDecodedFrames % 100 == 0)
        {
            //vm_string_printf( VM_STRING(". "));
            //fflush(stdout);
        }

        numDecodedFrames++;
        if (numDecodedFrames >= num_frames && num_frames != 0)
            break;
    }

    vm_tick t_end_all = GET_TICKS;
    Ipp64f all_time = (Ipp64f)(Ipp64s)(t_end_all-t_start_all);

    Ipp64f cpu_freq = (Ipp64f)vm_time_get_frequency();
    vm_string_printf(VM_STRING("%s\t"), SrcFileName);
    vm_string_printf(VM_STRING("%d\t"), numDecodedFrames);
    vm_string_printf(VM_STRING("%.4f s.\t"), encode_time/cpu_freq);
    vm_string_printf(VM_STRING("%.4f fps\t"), (Ipp64f)cpu_freq*numDecodedFrames/(Ipp64f)(encode_time));
    vm_string_printf(VM_STRING("All - %.4f fps\n"), (Ipp64f)cpu_freq*numDecodedFrames/(Ipp64f)(all_time));

#ifdef USE_DETAILED_H264_TIMING
    vm_string_printf(VM_STRING("CABAC/CAVLC - decoding time   %.4f s.\n"), clsTimingInfo->decode_time/cpu_freq);
    vm_string_printf(VM_STRING("reconstruct time              %.4f s.\n"), clsTimingInfo->reconstruction_time/cpu_freq);
    vm_string_printf(VM_STRING("deblocking time               %.4f s.\n"), clsTimingInfo->deblocking_time/cpu_freq);
    vm_string_printf(VM_STRING("summary time on all CPU cores %.4f s.\n"), (clsTimingInfo->deblocking_time + clsTimingInfo->decode_time + clsTimingInfo->reconstruction_time)/cpu_freq);
#endif

    if(f_dst)
        vm_file_close(f_dst);

    delete color;

    if (perf_file)
    {
        vm_string_fprintf(perf_file, VM_STRING("%s,"), SrcFileName);
        vm_string_fprintf(perf_file, VM_STRING("%d,"), numDecodedFrames);
        vm_string_fprintf(perf_file, VM_STRING("%.4f,"), encode_time/cpu_freq);
        vm_string_fprintf(perf_file, VM_STRING("%.4f,"), (Ipp64f)cpu_freq*numDecodedFrames/(Ipp64f)(encode_time));
#ifdef USE_DETAILED_H264_TIMING
        vm_string_fprintf(perf_file, VM_STRING("%.2f\t"), clsTimingInfo->decode_time/cpu_freq);
        vm_string_fprintf(perf_file, VM_STRING("%.2f\t"), clsTimingInfo->reconstruction_time/cpu_freq);
        vm_string_fprintf(perf_file, VM_STRING("%.2f\t"), clsTimingInfo->deblocking_time/cpu_freq);
        vm_string_fprintf(perf_file, VM_STRING("%.2f\t"), (clsTimingInfo->deblocking_time + clsTimingInfo->decode_time + clsTimingInfo->reconstruction_time)/cpu_freq);
#endif
        vm_string_fprintf(perf_file, VM_STRING("%.4f,\n"), (Ipp64f)cpu_freq*numDecodedFrames/(Ipp64f)(all_time));

        vm_file_close(perf_file);
    }

#ifdef VM_MALLOC
    vm_string_printf("Mem usage MAX: %d\n", vm_malloc_array.GetMemUsageMax() );
#endif /* VM_MALLOC */

    return 0;
}

out is a pointer which points to an object of a class called VideoData :)

Yeah, but what is the need to put get between the pointer out anf the other object?

Plz look again to the code:
out.get ( )->Meta ( ).dump ( );

if it was out->Meta ( ).dump ( ); maybe i can understand that it's nested object, but it's out.get ( )->Meta ( ).dump ( ); ???

Yeah, but what is the need to put get between the pointer out anf the other object?

If you let a pointer point to a specific object, the arrow operator is used to access the (public) data members of that object (you can't use a . to call them because out is a pointer) out.get ( )[B]->[/B]Meta ( ).dump ( ); , take a look at this link: http://www.cplusplus.com/reference/std/memory/auto_ptr/get/ (that's the get() you mean)

Do you understand it now?

Ok, thank you so much ;-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.