<commit_before>/*
 *  decodeoutput.cpp - decode outputs
 *
 *  Copyright (C) 2011-2014 Intel Corporation
 *    Author: <NAME><<EMAIL>>
 *    Author: <NAME> <<EMAIL>>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 2.1
 *  of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301 USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "decodeoutput.h"

#include "common/log.h"
#include "common/utils.h"
#include <assert.h>
#include <va/va.h>
#ifdef __ENABLE_X11__
#include <X11/Xlib.h>
#endif

#ifdef __ENABLE_TESTS_GLES__
#include "./egl/gles2_help.h"
#include "egl/egl_util.h"
#endif

bool DecodeOutput::setVideoSize(int width, int height)
{
    m_width = width;
    m_height = height;
    return true;
}

DecodeOutput::DecodeOutput(IVideoDecoder* decoder)
    :m_decoder(decoder), m_width(0), m_height(0), m_renderFrames(0)
{

}

Decode_Status DecodeOutput::processOneFrame(bool drain)
{
    Decode_Status status = renderOneFrame(drain);

    if (status == RENDER_SUCCESS)
        m_renderFrames++;

    m_decoder->renderDone(&m_frame);
    return status;
}

Decode_Status DecodeOutputNull::renderOneFrame(bool drain)
{
    m_frame.memoryType = VIDEO_DATA_MEMORY_TYPE_SURFACE_ID;
    m_frame.width = 0;
    m_frame.height = 0;
    m_frame.fourcc = 0;

    Decode_Status status = m_decoder->getOutput(&m_frame, drain);
    vaSyncSurface((void*)(m_frame.handle), m_frame.internalID);
    return status;
}

struct ColorConvert
{
    ColorConvert(uint32_t destFourcc)
        :m_destFourcc(destFourcc) {}
    VideoFrameRawData* convert(VideoFrameRawData* frame)
    {
        if (frame->fourcc == m_destFourcc) {
            //pass through
            return frame;
        }
        assert(m_destFourcc == VA_FOURCC_I420 && frame->fourcc == VA_FOURCC_NV12);

        uint32_t width[3];
        uint32_t height[3];
        uint32_t planes;
        if (!getPlaneResolution(frame->fourcc, frame->width, frame->height, width, height, planes))
            return NULL;
        return NV12ToI420(frame, width, height);<commit_msg>tests: only sync the surface when getoutput return success<commit_after>/*
 *  decodeoutput.cpp - decode outputs
 *
 *  Copyright (C) 2011-2014 Intel Corporation
 *    Author: <NAME><<EMAIL>>
 *    Author: <NAME> <<EMAIL>>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 2.1
 *  of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301 USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "decodeoutput.h"

#include "common/log.h"
#include "common/utils.h"
#include <assert.h>
#include <va/va.h>
#ifdef __ENABLE_X11__
#include <X11/Xlib.h>
#endif

#ifdef __ENABLE_TESTS_GLES__
#include "./egl/gles2_help.h"
#include "egl/egl_util.h"
#endif

bool DecodeOutput::setVideoSize(int width, int height)
{
    m_width = width;
    m_height = height;
    return true;
}

DecodeOutput::DecodeOutput(IVideoDecoder* decoder)
    :m_decoder(decoder), m_width(0), m_height(0), m_renderFrames(0)
{

}

Decode_Status DecodeOutput::processOneFrame(bool drain)
{
    Decode_Status status = renderOneFrame(drain);

    if (status == RENDER_SUCCESS)
        m_renderFrames++;

    m_decoder->renderDone(&m_frame);
    return status;
}

Decode_Status DecodeOutputNull::renderOneFrame(bool drain)
{
    m_frame.memoryType = VIDEO_DATA_MEMORY_TYPE_SURFACE_ID;
    m_frame.width = 0;
    m_frame.height = 0;
    m_frame.fourcc = 0;

    Decode_Status status = m_decoder->getOutput(&m_frame, drain);
    if (status == RENDER_SUCCESS)
        vaSyncSurface((void*)(m_frame.handle), m_frame.internalID);
    return status;
}

struct ColorConvert
{
    ColorConvert(uint32_t destFourcc)
        :m_destFourcc(destFourcc) {}
    VideoFrameRawData* convert(VideoFrameRawData* frame)
    {
        if (frame->fourcc == m_destFourcc) {
            //pass through
            return frame;
        }
        assert(m_destFourcc == VA_FOURCC_I420 && frame->fourcc == VA_FOURCC_NV12);

        uint32_t width[3];
        uint32_t height[3];
        uint32_t planes;
        if (!getPlaneResolution(frame->fourcc, frame->width, frame->height, width, height, planes))
            return NULL;
        return NV12ToI420(frame, width, height);
{'fraction_non_alphanumeric': 0.10178538560647893, 'fraction_numerical': 0.01914227866740291, 'mean_word_length': 3.6089906700593724, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6018978', 'n_tokens_mistral': 1835, 'n_tokens_neox': 1740, 'n_words': 498}