text:
package com.anybeen.mark.imageeditor.view;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.widget.RadioButton;
import android.widget.Toast;

import com.anybeen.mark.imageeditor.component.ZipExtractorTask;
import com.anybeen.mark.imageeditor.utils.CommonUtils;
import com.anybeen.mark.imageeditor.utils.Const;
import com.anybeen.mark.imageeditor.utils.LogUtil;
import com.anybeen.mark.yinjiimageeditorlibrary.R;

import java.io.File;

/**
 * Created by wjk on 2015/6/12.
 * 可显示选中/非选中两种状态的View 用于字幕位置/字体类型选择器
 */
public class SelectableView extends RadioButton{

    /**下载进度条画笔*/
    private  Paint mRingPaint;
    private  Paint mRingPaintBg;
    private Context context;
    private int mCurrNormalBg;
    private int mRingRadius;
    private RectF oval;
    private ProgressReceiver receiver;
    private OnDownloadCompleteListener downloadCompleteListener;
    private boolean isReceiverRegisted;

    @Override
    public void setChecked(boolean checked) {
        super.setChecked(checked);
        if(checked){
            setBackgroundResource(R.drawable.shape_font_btn_checked_bg);
        }else {
            setBackgroundResource(mCurrNormalBg);
        }
    }

    public SelectableView(Context context) {
        super(context, null);
    }

    public SelectableView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        //初始化显示样式:可用、不可用
        boolean shouldInitPaint = initView();
        if(shouldInitPaint){
            mRingPaint = new Paint();
            mRingPaint.setAntiAlias(true);
            mRingPaint.setColor(context.getResources().getColor(R.color.common_red));
            mRingPaint.setStyle(Paint.Style.STROKE);

            mRingPaintBg = new Paint();
            mRingPaintBg.setAntiAlias(true);
            mRingPaintBg.setColor(context.getResources().getColor(R.color.grey_bg));
            mRingPaintBg.setStyle(Paint.Style.STROKE);

            oval = new RectF();
        }

       /* 向配置文件中写入配置
        Properties prop = new Properties();
        prop.put("prop1", "abc");
        prop.put("prop2", "1");
        prop.put("prop3", "3.14");
        File file = new File(Const.FONT_PATH+ File.separator+"font.properties");
        if(!file.exists()) {
            CommUtils.copyFiles2Assets(context, "fonts/font.properties", Const.FONT_PATH);
        }
        CommUtils.saveConfig(file, prop);*/
    }

    public boolean initView() {
        boolean shouldInitPaint = false;
        if(getFontType()==null){
            setBackgroundResource(R.drawable.shape_font_btn_disable_bg);
            setSelected(false);
            mCurrNormalBg = R.drawable.shape_font_btn_disable_bg;
            shouldInitPaint = true;
        }else{
            setBackgroundResource(R.drawable.shape_font_btn_enable_bg);
            setSelected(true);
            mCurrNormalBg = R.drawable.shape_font_btn_enable_bg;
        }
        return shouldInitPaint;
    }

    /**
     * 获取当前对应字体文件大小
     * @return String  xxMB
     */
    public String getFontSize(){
        String fontSize = null;
        String fontName = (String) getTag();
        File file = new File(Const.FONT_PATH+ File.separator+"font.properties");
        if(file.exists()) {
            fontSize = CommonUtils.getFontConfigProperties(file, context).getProperty(fontName);
        }else{
            CommonUtils.copyFiles2Assets(context,"fonts/font.properties",Const.FONT_PATH);
            getFontSize();
        }
        if(fontSize==null||fontSize.isEmpty()){
            fontSize="3M";
        }
        return fontSize;
    }

    /**
     * 获取当前位置上的字体对象,如果本地存在就返回,否则返回Null
     * @return 字体对象
     */
    public Typeface getFontType(){
        String fontName =  (String) getTag();
        if(fontName.equals("default")){
            return Typeface.create(Typeface.DEFAULT,Typeface.NORMAL);
        }
        File file = new File(Const.FONT_PATH+ File.separator+fontName);
        if(file.exists()) {
            Typeface typeface= null;
            try {
                typeface = Typeface.createFromFile(file);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return typeface;
        }else{
            return null;
        }
    }

    /**
     * 下载字体到本地
     */
    public void downloadFont(OnDownloadCompleteListener downloadCompleteListener) {
        this.downloadCompleteListener = downloadCompleteListener;
        Intent intent = new Intent();
        String fontName = ((String) getTag()).replace("ttf","zip");
        intent.putExtra("fontName",fontName);
        intent.setAction(Const.INTENT_ACTION_FONT_DOWNLOAD);
        String name = context.getPackageName();
        intent.setPackage(context.getPackageName());
        context.startService(intent);
        registerReceiver();
    }

    private void registerReceiver() {
        //注册广播
        receiver = new ProgressReceiver();
        IntentFilter filter = new IntentFilter("com.anybeen.mark.app.download_progress");
        context.registerReceiver(receiver, filter);
        isReceiverRegisted = true;
    }
    private void unRegisterReceiver() {
        //注销广播
        if(receiver!=null&&isReceiverRegisted) {
            context.unregisterReceiver(receiver);
            isReceiverRegisted = false;
        }
    }

    private boolean isDownloading = false;
    private  Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case DOWNLOAD_FAILED:
                    isDownloading = false;
                    Toast.makeText(context, "下载失败,请稍后重试", Toast.LENGTH_SHORT).show();
                    break;
                case DOWNLOAD_OK:
                    mProgress = -1;
                    unRegisterReceiver();
                    isDownloading = false;
                    doZipExtractorWork(downloadCompleteListener);
                    break;
                case DOWNLOADING:
                    invalidate();
                    isDownloading = true;
                    break;
            }
        }
    };

    public void doZipExtractorWork(OnDownloadCompleteListener downloadCompleteListener){
        String fontName = ((String) getTag()).replace("ttf","zip");
        String pathIn = Const.FONT_PATH + File.separator + fontName;
        String pathOut = Const.FONT_PATH + File.separator;
        ZipExtractorTask task = new ZipExtractorTask(pathIn, pathOut, context, true,downloadCompleteListener);
        task.execute();
    }

    public boolean isDownloading(){
        return isDownloading;
    }

    private static final int DOWNLOAD_OK = 221;
    private static final int DOWNLOAD_FAILED = 222;
    private static final int DOWNLOADING =223 ;
    private int ringWidth = 10;
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        mRingRadius = (getMeasuredWidth()/2)*3/5;
        ringWidth = (getMeasuredWidth()/2)/7;
    }
    private int mProgress = -1;
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if(mRingPaint!=null&&mProgress>=0){
            int mXCenter = getWidth() / 2;
            int mYCenter = getHeight() / 2;
            oval.left = mXCenter - mRingRadius-ringWidth;
            oval.top = mYCenter - mRingRadius-ringWidth;
            oval.right = mXCenter + mRingRadius+ringWidth;
            oval.bottom = mYCenter + mRingRadius+ringWidth;
            mRingPaint.setStrokeWidth(ringWidth);
            mRingPaintBg.setStrokeWidth(ringWidth);
            canvas.drawArc(oval, -90, 360, false, mRingPaintBg);
            canvas.drawArc(oval, -90, ((float)mProgress / 100) * 360, false, mRingPaint);
        }
    }

    public class ProgressReceiver extends BroadcastReceiver{
        public ProgressReceiver(){}
        @Override
        public void onReceive(Context context, Intent intent) {
            if (handler != null) {
                if (intent.getStringExtra("tag").equals((String) getTag())) {
                    //更新进度
                    int progress = intent.getIntExtra("progress", -3);
                    if (progress == -2) { //下载出错
                        handler.sendEmptyMessageDelayed(DOWNLOAD_FAILED, 100);
                    } else if (progress == 100) {
                        handler.sendEmptyMessageDelayed(DOWNLOAD_OK, 100);
                    } else if(progress>0){
                        mProgress = progress;
                        handler.sendEmptyMessageDelayed(DOWNLOADING, 5);
                        LogUtil.e("wjk", "当前下载进度:" + mProgress);
                    }
                } else {
                    mProgress = 0;
                    handler.sendEmptyMessageDelayed(DOWNLOADING, 5);
                }
            }
        }
    }

    public interface OnDownloadCompleteListener{
         void onDownloadComplete();
    }
}


text:
import util
from game import Agent
from game import Directions
from keyboardAgents import KeyboardAgent
import inference

class BustersAgent:
  "An agent that tracks and displays its beliefs about ghost positions."

  def __init__( self, index = 0, inference = "ExactInference", ghostAgents = None ):
    inferenceType = util.lookup(inference, globals())
    self.inferenceModules = [inferenceType(a) for a in ghostAgents]

  def registerInitialState(self, gameState):
    "Initializes beliefs and inference modules"
    import __main__
    self.display = __main__._display
    for inference in self.inferenceModules: inference.initialize(gameState)
    self.ghostBeliefs = [inf.getBeliefDistribution() for inf in self.inferenceModules]
    self.firstMove = True

  def observationFunction(self, gameState):
    "Removes the ghost states from the gameState"
    agents = gameState.data.agentStates
    gameState.data.agentStates = [agents[0]] + [None for i in range(1, len(agents))]
    return gameState

  def getAction(self, gameState):
    "Updates beliefs, then chooses an action based on updated beliefs."
    for index, inf in enumerate(self.inferenceModules):
      if not self.firstMove: inf.elapseTime(gameState)
      self.firstMove = False
      inf.observeState(gameState)
      self.ghostBeliefs[index] = inf.getBeliefDistribution()
    self.display.updateDistributions(self.ghostBeliefs)
    return self.chooseAction(gameState)

  def chooseAction(self, gameState):
    "By default, a BustersAgent just stops.  This should be overridden."
    return Directions.STOP

class BustersKeyboardAgent(BustersAgent, KeyboardAgent):
  "An agent controlled by the keyboard that displays beliefs about ghost positions."

  def __init__(self, index = 0, inference = "ExactInference", ghostAgents = None):
    KeyboardAgent.__init__(self, index)
    BustersAgent.__init__(self, index, inference, ghostAgents)

  def getAction(self, gameState):
    return BustersAgent.getAction(self, gameState)

  def chooseAction(self, gameState):
    return KeyboardAgent.getAction(self, gameState)

from distanceCalculator import Distancer
from game import Actions
from game import Directions

class GreedyBustersAgent(BustersAgent):
  "An agent that charges the closest ghost."

  def registerInitialState(self, gameState):
    "Pre-computes the distance between every two points."
    BustersAgent.registerInitialState(self, gameState)
    self.distancer = Distancer(gameState.data.layout, False)

  def chooseAction(self, gameState):
    """
    First computes the most likely position of each ghost that
    has not yet been captured, then chooses an action that brings
    Pacman closer to the closest ghost (in maze distance!).

    To find the maze distance between any two positions, use:
    self.distancer.getDistance(pos1, pos2)

    To find the successor position of a position after an action:
    successorPosition = Actions.getSuccessor(position, action)

    livingGhostPositionDistributions, defined below, is a list of
    util.Counter objects equal to the position belief distributions
    for each of the ghosts that are still alive.  It is defined based
    on (these are implementation details about which you need not be
    concerned):

      1) gameState.getLivingGhosts(), a list of booleans, one for each
         agent, indicating whether or not the agent is alive.  Note
         that pacman is always agent 0, so the ghosts are agents 1,
         onwards (just as before).

      2) self.ghostBeliefs, the list of belief distributions for each
         of the ghosts (including ghosts that are not alive).  The
         indices into this list should be 1 less than indices into the
         gameState.getLivingGhosts() list.

    """
    pacmanPosition = gameState.getPacmanPosition()
    legal = [a for a in gameState.getLegalPacmanActions()]
    livingGhosts = gameState.getLivingGhosts()
    livingGhostPositionDistributions = [beliefs for i,beliefs
                                        in enumerate(self.ghostBeliefs)
                                        if livingGhosts[i+1]]

    # find closest ghost
    closestGhostPos = None
    closestGhostDist = float("inf")
    for belief in livingGhostPositionDistributions:
      # most likely position is the position with largest belief
      pos = belief.argMax()
      distance = self.distancer.getDistance(pacmanPosition, pos)
      # update closest ghost
      if distance < closestGhostDist:
        closestGhostDist = distance
        closestGhostPos = pos

    # best action
    bestAction = None
    minDist = float("inf")

    for action in legal:
      # compute distance between ghost and pacman successor position
      successorPosition = Actions.getSuccessor(pacmanPosition, action)
      dist = self.distancer.getDistance(successorPosition, closestGhostPos)

      # update best action
      if dist < minDist:
        minDist = dist
        bestAction = action

    return bestAction

redpajama_set_name: RedPajamaGithub


text:
module Azure::Network::Mgmt::V2019_09_01
  module Models
    #
    # Bastion Shareable Link.
    #
    class BastionShareableLink

      include MsRestAzure

      # @return [VM] Reference of the virtual machine resource.
      attr_accessor :vm

      # @return [String] The unique Bastion Shareable Link to the virtual
      # machine.
      attr_accessor :bsl

      # @return [String] The time when the link was created.
      attr_accessor :created_at

      # @return [String] Optional field indicating the warning or error message
      # related to the vm in case of partial failure
      attr_accessor :message

      #
      # Mapper for BastionShareableLink class as Ruby Hash.
      # This will be used for serialization/deserialization.
      #
      def self.mapper()
        {
          client_side_validation: true,
          required: false,
          serialized_name: 'BastionShareableLink',
          type: {
            name: 'Composite',
            class_name: 'BastionShareableLink',
            model_properties: {
              vm: {
                client_side_validation: true,
                required: true,
                serialized_name: 'vm',
                type: {
                  name: 'Composite',
                  class_name: 'VM'
                }
              },
              bsl: {
                client_side_validation: true,
                required: false,
                read_only: true,
                serialized_name: 'bsl',
                type: {
                  name: 'String'
                }
              },
              created_at: {
                client_side_validation: true,
                required: false,
                read_only: true,
                serialized_name: 'createdAt',
                type: {
                  name: 'String'
                }
              },
              message: {
                client_side_validation: true,
                required: false,
                read_only: true,
                serialized_name: 'message',
                type: {
                  name: 'String'
                }
              }
            }
          }
        }
      end
    end
  end
end


text:
//===----------------------------------------------------------------------===//
//
//                         Peloton
//
// model_util.h
//
// Identification: src/include/brain/util/model_util.h
//
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//

#pragma once

#include "brain/util/eigen_util.h"

namespace peloton {
namespace brain {

// Forward declarations
class BaseForecastModel;

class ModelUtil {
 public:
  /**
   * Simple MSE loss function: mean((y - pred)**2)
   * @param ytrue: True labels
   * @param ypred: Predicted labels
   * @return: loss value
   */
  static float MeanSqError(const matrix_eig &ytrue, const matrix_eig &ypred);

  /**
   * Function to check for early stopping criteria. This API is similar to
   * **keras.callbacks.EarlyStopping** and based on below references
   * @param val_losses: vector of validation losses
   * @param patience: number of epochs to wait for a threshold change in loss
   * @param delta: minimum needed threshold change to continue training
   * @return: True if one should stop.
   * Refences: (1) https://stats.stackexchange.com/q/231061/72908
   *           (2) Check: "Early Stopping - but when?" for a more detailed
   *           suite of methods.
   */
  static bool EarlyStop(vector_t val_losses, size_t patience, float delta);

  /**
   * Utility function to create a batch of the given data
   * , generally useful to be fed into a TF model.
   * The method of creating batches is specialized for Time series
   * forecasting, hence placed here.
   * Batches are in batch-major format. => (Bsz, SeqLen, FeatLen)
   * The way of creating batches closely follows QB5000 code, except that
   * the time-major format there is converted to this Batch-major one.
   * Refer to ModelUtilTest to better understand whats happening here.
   */
  static void GetBatch(const BaseForecastModel &model, const matrix_eig &mat,
                       size_t batch_offset, size_t bsz,
                       std::vector<matrix_eig> &data,
                       std::vector<matrix_eig> &target,
                       bool time_major = false);

  /**
   * Converts a dataset/workload(upto RAM sized) passed to it into (X, y)
   * batches useful for either training/validation of models working on batches
   * of data. This is only meant for forecastable models The produced batches
   * are of form [num_batches(outer std::vector), bsz/num_seq(inner
   * std::vector), (seq_len, feat_len)(eigen matrix)]
   */
  static void GetBatches(const BaseForecastModel &model, const matrix_eig &mat,
                         size_t batch_size,
                         std::vector<std::vector<matrix_eig>> &data,
                         std::vector<std::vector<matrix_eig>> &target,
                         bool time_major = false);

  // Convert a dataset into batches
  static void GetBatches(const BaseForecastModel &model, const matrix_eig &mat,
                         size_t batch_size,
                         std::vector<std::vector<matrix_eig>> &data_batches);

  /**
   * Split the data into X, y which can be featurized
   */
  static void FeatureLabelSplit(const BaseForecastModel &model,
                                const matrix_eig &data, matrix_eig &X,
                                matrix_eig &y);

  /**
   * Given data of the form (timesteps, feat_len), this function generates
   * a feature matrix appropriate for learning a forecast model.
   * Useful for Linear and Kernel Regression Models
   */
  static void GenerateFeatureMatrix(const BaseForecastModel &model,
                                    const matrix_eig &data,
                                    matrix_eig &processed_features);
};
}  // namespace brain
}  // namespace peloton


text:
<?php

namespace Acme\BlogBundle\Controller;

use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Controller\Annotations;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Opensoft\Tfs\Rest\Client;

class MantisController extends FOSRestController
{

 /**
     * appel API REST TFS
     *
     * @param string $method    : GET, POST, PUT, PATCH
     * @param string $url : url du web service
     *
     * @return boolean
     */

    function callAPI($method, $url)
    {
        $data = array();
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

        switch ($method)
        {
            case "POST":
                curl_setopt($curl, CURLOPT_POST, 1);

                if ($data)
                    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                break;

            case "PUT":
                curl_setopt($curl, CURLOPT_PUT, 1);
                break;

            case "PATCH":

                $headers = array('Content-Type: application/json-patch+json');

                curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
                curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

                break;

            default:
                if ($this->_data)
                    $url = sprintf("%s?%s", $url, http_build_query($data));

        }

        // Optional Authentication:
        curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($curl, CURLOPT_USERPWD, $this->getLogin().":".$this->getPassword());

        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

        $result = curl_exec($curl);

        curl_close($curl);

        return $result;
    }

    /**
     * Connexion au Bug Tracker TFS
     *
     * @param string $bt_login    : login bug tracker de l'utilisateur
     * @param string $bt_password : mot de passe bug tracker de l'utilisateur
     *
     * @return boolean
     */
    function connection($login, $password)
    {
        $this->setLogin($login);
        $this->setPassword($password);

        $connection = $this->callAPI('GET', 'https://modistfs.visualstudio.com/DefaultCollection/_apis/profile/profiles/me?api-version=1.0');

        if($this->isJson($connection)) {
            $connection = json_decode($connection);
            if(!empty($connection->emailAddress)) {
                return  $connection;

            } else {
                return 'error';
            }

        }  else {
            return 'error';
        }

    }

    function testAction() {

        $client = new Client(
            // your tfs/vso
            'https://modistfs.visualstudio.com',
            // your collection
            'DefaultCollection',
            // (optional) raw options to pass to guzzle (ntlm example here)
            [
                'curl' => [
                    CURLOPT_HTTPAUTH => CURLAUTH_NTLM,
                    CURLOPT_USERPWD => 'quentinbogoss58@hotmail.fr:MC724exp'
                ]
            ]
        );

        // retrieve a work item by its ID
        $response = $client->workItemTracking()->getWorkItem(131);

        // get the result as an array
        print_r($response->asArray());

        // follow hypermedia links
        //$response = $response->follow('workItemHistory');

        //print_r($response->asArray());
    }

}


text: Personlized twitch chat bot


text:
package ch.vorburger.learning;

import java.util.Objects;

import org.eclipse.jdt.annotation.Nullable;

import ch.vorburger.utils.EvenMoreObjects;

public class UserID {
	// TODO https://immutables.github.io

	private final String scheme;
	private final String uuid;
	// TODO private final Locale locale;

	public UserID(String scheme, String uuid) {
		super();
		this.scheme = scheme;
		this.uuid = uuid;
	}

	public String getScheme() {
		return scheme;
	}

	public String getUuid() {
		return uuid;
	}

	@Override
	public int hashCode() {
		return Objects.hash(scheme, uuid);
	}

	@Override
	public boolean equals(@Nullable Object other) {
		return EvenMoreObjects.equalsHelper(this, other,
				(one, another) -> Objects.equals(one.scheme, another.scheme)
				               && Objects.equals(one.uuid, another.uuid));
	}

	@Override
	public String toString() {
		return new StringBuilder(scheme).append("::").append(uuid).toString();
	}

}


text:
<?xml version="1.0" encoding="UTF-8"?>

<rootTag>
  <Award>
    <AwardTitle>EXP-SA: Nanofibril Films for Dual-Sensing Explosives Detection</AwardTitle>
    <AwardEffectiveDate>08/15/2008</AwardEffectiveDate>
    <AwardExpirationDate>08/31/2011</AwardExpirationDate>
    <AwardAmount>299893</AwardAmount>
    <AwardInstrument>
      <Value>Standard Grant</Value>
    </AwardInstrument>
    <Organization>
      07020000
      <Directorate>
        <LongName>Directorate For Engineering</LongName>
      </Directorate>
      <Division>
        <LongName>Div Of Chem, Bioeng, Env, & Transp Sys</LongName>
      </Division>
    </Organization>
    <ProgramOfficer>
      <SignBlockName>Bruce K. Hamilton</SignBlockName>
    </ProgramOfficer>
    <AbstractNarration>TITLE: EXP-SA: Nanofibril Films for Dual-Sensing Explosives Detection<br/>PI name: Ling Zang<br/>Institution: Southern Illinois University at Carbondale <br/><br/>Proposal Number: 0730667<br/><br/><br/><br/>This research will build upon unique molecular assembly techniques pioneered in the PIs' laboratories. By controlling the nanoscale morphology of fluorescent materials, they have demonstrated efficient vapor phase explosives detection that is independent of film thickness. By modifying the molecular structure and improving fabrication of the assembled arylene-ethynylene macrocycles (AREs), they can optimize the fluorescent quenching-based sensory response. An alternative transduction mechanism is also proposed which relies on measuring conductivity changes in the materials.</AbstractNarration>
    <MinAmdLetterDate>04/23/2009</MinAmdLetterDate>
    <MaxAmdLetterDate>04/23/2009</MaxAmdLetterDate>
    <ARRAAmount/>
    <AwardID>0931467</AwardID>
    <Investigator>
      <FirstName>Ling</FirstName>
      <LastName>Zang</LastName>
      <EmailAddress>lzang@eng.utah.edu</EmailAddress>
      <StartDate>04/23/2009</StartDate>
      <EndDate/>
      <RoleCode>Principal Investigator</RoleCode>
    </Investigator>
    <Institution>
      <Name>University of Utah</Name>
      <CityName>SALT LAKE CITY</CityName>
      <ZipCode>841128930</ZipCode>
      <PhoneNumber>8015816903</PhoneNumber>
      <StreetAddress>75 S 2000 E</StreetAddress>
      <CountryName>United States</CountryName>
      <StateName>Utah</StateName>
      <StateCode>UT</StateCode>
    </Institution>
    <FoaInformation>
      0308000
      <Name>Industrial Technology</Name>
    </FoaInformation>
    <ProgramElement>
      7653
      <Text>EXPLOSIVES & RLTD THREATS EXP</Text>
    </ProgramElement>
    <ProgramReference>
      0000
      <Text>UNASSIGNED</Text>
    </ProgramReference>
    <ProgramReference>
      019E
      <Text>SENSORS AND SENSING</Text>
    </ProgramReference>
    <ProgramReference>
      134E
      <Text>EXPLOSIVES & THRTS EXP SMALL</Text>
    </ProgramReference>
    <ProgramReference>
      OTHR
      <Text>OTHER RESEARCH OR EDUCATION</Text>
    </ProgramReference>
  </Award>
</rootTag>


text:
undersorejs template engine adapter for Chrome Extension Content Security Policy (CSP)

https://developer.chrome.com/apps/manifest/sandbox

https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/sandbox

usage:

    var template = $('#form-template').html();
    _.stemplate(template, {app : app.config}).done(function(tmpl){
      $(tmpl).appendTo('.row');

      $('form').on('submit', function(evt){
        evt.preventDefault();
        evt.stopPropagation();
        submitForm(evt);
      })
    })


text:
package com.sequenceiq.cloudbreak.reactor.api.event.cluster.install;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sequenceiq.cloudbreak.reactor.api.event.StackEvent;
import com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionType;

public class FinalizeClusterInstallRequest extends StackEvent {

    private final ProvisionType provisionType;

    @JsonCreator
    public FinalizeClusterInstallRequest(
            @JsonProperty("resourceId") Long stackId,
            @JsonProperty("provisionType") ProvisionType provisionType) {
        super(stackId);
        this.provisionType = provisionType;
    }

    public ProvisionType getProvisionType() {
        return provisionType;
    }
}


text:
namespace example_01 { // -> the "how to do it" section

void run() {
    struct Control {
        enum class TxtVertAlign { Top, Middle, Bottom };
        enum class TxtHorAlign { Left, Middle, Right };

        const int DefaultHeight = 14;
        const int DefaultWidth = 80;

        TxtVertAlign valign = TxtVertAlign::Middle;
        TxtHorAlign halign = TxtHorAlign::Left;

        std::string txt;

        Control(std::string const & t) : txt(t) {}

        Control(std::string const & t, TxtVertAlign const va, TxtHorAlign const ha)
            : txt(t), valign(va), halign(ha) {}
    };
}
} // example_01

#include <iostream>
#include <string>
namespace example_02 { // -> the "how it works..."

void run() {
    struct Point {
        double X, Y;
        Point(double const x = 0.0, double const y = 0.0) : X(x), Y(y) {}
    };

    struct foo {
        foo() { std::cout << "default ctor\n"; }
        foo(std::string const & txt) { std::cout << "ctor '" << txt << "\n"; }
        foo(foo const & other) { std::cout << "copy ctor\n"; }
        foo(foo&& other) { std::cout << "move ctor\n"; }
        foo& operator=(foo const & other) { std::cout << "assignment\n"; return *this; }
        foo& operator=(foo&& other) { std::cout << "move assignment\n"; return *this; }

        ~foo() { std::cout << "dtor\n"; }
    };

    {
        struct bar {
            foo f;

            bar(foo const & value) { f = value; }
        };

        foo f; bar b(f);
    }

    {
        std::cout << "\n";
        struct bar {
            foo f;
            bar(foo const & value) : f(value) {}
        };
        foo f; bar b(f);
    }

    {
        enum class TxtFlow { LeftToRight, RightToLeft };

        struct Control {
            int const DefaultHeight = 20;
            int const DefaultWidth = 100;

            TxtFlow txtFlow = TxtFlow::LeftToRight;
            std::string txt;

            Control(std::string t) : txt(t) {}
        };
    }

    {
        std::cout << "\n";
        struct bar {
            foo f{"default value"};

            bar() : f{"ctor initializer"} {}
        };
        bar b;
    }

}
} // example_02

int main() {
    example_01::run();
    example_02::run();

    return 0;
}


text:
SET(Doc "The kernel header directory (path to <linux/bpf.h>)")
IF(KernelHeaders_INCLUDE_PATH)
  FIND_PATH(KernelHeaders_INCLUDE_DIR NAMES "linux/bpf.h" PATHS ${KernelHeaders_INCLUDE_PATH} DOC ${Doc} NO_DEFAULT_PATH)
ELSE()
  FIND_PATH(KernelHeaders_INCLUDE_DIR NAMES "linux/bpf.h" DOC ${Doc})
ENDIF()

SET(KernelHeaders_FOUND FALSE)

IF(KernelHeaders_INCLUDE_DIR)
  SET(KernelHeaders_FOUND TRUE)
  message("Found Linux kernel headers. KernelHeaders_INCLUDE_DIR: ${KernelHeaders_INCLUDE_DIR}")
ELSE()
  MESSAGE(WARNING "Couldn't find kernel headers. Have you set KernelHeaders_INCLUDE_PATH to the directory containing linux/bpf.h? Try again with cmake -DKernelHeaders_INCLUDE_PATH=/path/to/kernel/usr/include/.")
  SET(KernelHeaders_FOUND FALSE)
ENDIF()


text:
using System;
using System.Net;
using Independentsoft.Exchange;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            NetworkCredential credential = new NetworkCredential("username", "password");
            Service service = new Service("https://myserver/ews/Exchange.asmx", credential);

            try
            {
                Mailbox mailbox = new Mailbox("John@mydomain.com");

                DelegateUser delegateUser = new DelegateUser("Mark@mydomain.com");
                delegateUser.CalendarFolderPermissionLevel = DelegateFolderPermissionLevel.Author;

                DelegateUserResponse response = service.AddDelegate(mailbox, delegateUser);
            }
            catch (ServiceRequestException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.WriteLine("Error: " + ex.XmlMessage);
                Console.Read();
            }
            catch (WebException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.Read();
            }
        }
    }
}


text:
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PopulateContentByIdResponseHydrator.cs" company="Gravypowered">
//   Copyright 2013 Aaron Job
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
// </copyright>
// <summary>
//   Defines the PopulateContentByIdResponseHydrator type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Gravyframe.Service.Content.Tasks
{
    using System.Collections.Generic;

    using Gravyframe.Configuration;
    using Gravyframe.Data.Content;

    /// <summary>
    /// The populate content by id response hydrator.
    /// </summary>
    public class PopulateContentByIdResponseHydrator : ContentResponseHydrator
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PopulateContentByIdResponseHydrator"/> class.
        /// </summary>
        /// <param name="contentDao">
        /// The content dao.
        /// </param>
        /// <param name="contentConfiguration">
        /// The content configuration.
        /// </param>
        public PopulateContentByIdResponseHydrator(ContentDao<Models.Content> contentDao, IContentConfiguration contentConfiguration)
            : base(contentDao, contentConfiguration)
        {
        }

        /// <summary>
        /// The populate response.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <param name="response">
        /// The response.
        /// </param>
        public override void PopulateResponse(ContentRequest request, ContentResponse response)
        {
            response.Content = ContentDao.GetContent(request.ContentId);
        }

        /// <summary>
        /// The validate response.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see>
        ///     <cref>IEnumerable</cref>
        /// </see>
        ///     .
        /// </returns>
        public override IEnumerable<string> ValidateResponse(ContentRequest request)
        {
            if (string.IsNullOrEmpty(request.ContentId))
            {
                return new List<string> { ContentConfiguration.ContentCategoryIdError };
            }

            return new List<string>();
        }
    }
}


text:
<?php
/* @var $this PostController */
/* @var $data Post */
?>

	<?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:
	<?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>

	<?php echo CHtml::encode($data->getAttributeLabel('title')); ?>:
	<?php echo CHtml::encode($data->title); ?>

	<?php echo CHtml::encode($data->getAttributeLabel('content')); ?>:
	<?php echo CHtml::encode($data->content); ?>

	<?php echo CHtml::encode($data->getAttributeLabel('status')); ?>:
	<?php echo CHtml::encode($data->status); ?>

	<?php echo CHtml::encode($data->getAttributeLabel('create_time')); ?>:
	<?php echo CHtml::encode($data->create_time); ?>

	<?php echo CHtml::encode($data->getAttributeLabel('update_time')); ?>:
	<?php echo CHtml::encode($data->update_time); ?>

	<?php echo CHtml::encode($data->getAttributeLabel('author_id')); ?>:
	<?php echo CHtml::encode($data->author_id); ?>


text:
import TestBase from "../../../TestBase";
import {TwingMarkup} from "../../../../../../src/lib/markup";
import {TwingEnvironmentOptions} from "../../../../../../src/lib/environment-options";

export default class extends TestBase {
    getDescription() {
        return '"sandbox" tag ignore TwingMarkup';
    }

    getTemplates() {
        return {
            'foo.twig': `{{ markup }}
`,
            'index.twig': `{% sandbox %}
    {% include 'foo.twig' %}
{% endsandbox %}`
        };
    }

    getExpected() {
        return `Foo
`;
    }

    getEnvironmentOptions(): TwingEnvironmentOptions {
        return {
            autoescape: false
        };
    }

    getContext() {
        return {
            markup: new TwingMarkup('Foo', 'utf-8')
        }
    }
}


text:
package com.facebook.buck.cli;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import com.facebook.buck.testutil.integration.TemporaryPaths;
import com.facebook.buck.testutil.integration.ProjectWorkspace;
import com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult;
import com.facebook.buck.testutil.integration.TestDataHelper;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;

import org.junit.Rule;
import org.junit.Test;

import java.io.IOException;
import java.util.List;

public class AuditAliasCommandIntegrationTest {

  @Rule
  public TemporaryPaths tmp = new TemporaryPaths();

  @Test
  public void testBuckAliasList() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(
        this, "alias", tmp);
    workspace.setUp();

    ProcessResult result = workspace.runBuckCommand("audit", "alias", "--list");
    result.assertSuccess();

    // Remove trailing newline from stdout before passing to Splitter.
    String stdout = result.getStdout();
    assertTrue(stdout.endsWith("\n"));
    stdout = stdout.substring(0, stdout.length() - 1);

    List<String> aliases = Splitter.on('\n').splitToList(stdout);
    assertEquals(
        "Aliases that appear in both .buckconfig and .buckconfig.local should appear only once.",
        3,
        aliases.size());
    assertEquals(
        ImmutableSet.of("foo", "bar", "bar_ex"),
        ImmutableSet.copyOf(aliases));
  }

  @Test
  public void testBuckAliasListMap() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(
        this, "alias", tmp);
    workspace.setUp();

    ProcessResult result = workspace.runBuckCommand("audit", "alias", "--list-map");
    result.assertSuccess();

    // Remove trailing newline from stdout before passing to Splitter.
    String stdout = result.getStdout();
    assertTrue(stdout.endsWith("\n"));
    stdout = stdout.substring(0, stdout.length() - 1);

    List<String> aliases = Splitter.on('\n').splitToList(stdout);
    assertEquals(
        "Aliases that appear in both .buckconfig and .buckconfig.local should appear only once.",
        3,
        aliases.size());
    assertEquals(
        ImmutableSet.of("foo = //:bar_example", "bar = //:bar_example", "bar_ex = //:bar_example"),
        ImmutableSet.copyOf(aliases));
  }
}


text:
using System.Collections.Generic;
using Apache.Ignite.Core;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Log;
using Apache.Ignite.Log4Net;
using Core.Utils;
using IgniteService.Models;
using log4net;

namespace IgniteService
{
    public class IgniteService
    {
        private readonly ILogger _logger = new IgniteLog4NetLogger(LogManager.GetLogger("IgniteService"));
        private readonly IgniteServiceConfiguration _serviceConf;

        public IIgnite Ignite;
        public Dictionary<string, ICache<string, byte[]>> Caches;

        public IgniteService(IgniteServiceConfiguration serviceConf)
        {
            _serviceConf = serviceConf;
            Caches = new Dictionary<string, ICache<string, byte[]>>();
        }

        public void Start()
        {
            _logger.Info("IgniteService starting");
            Ignite = Ignition.Start(_serviceConf.IgniteConfiguration);

            // lets start all caches we have in configuration
            foreach (var cacheConf in _serviceConf.CacheConfigurations)
            {
                Caches.Add(cacheConf.Name, Ignite.GetOrCreateCache<string, byte[]>(cacheConf));
                _logger.Info("Cache name={0} created", cacheConf.Name);
            }

            //var entity = new Entity
            //{
            //    Name = "HoHo",
            //    Number = 1337,
            //    SubEntities = new List<SubEntity>
            //    {
            //        new SubEntity("HoHo sunentity")
            //    }
            //};
            //Cache.Put(entity.Name, SerializationHelper.Serialize(entity));
        }
    }
}


text:
/*
 * @file        Exynos_OMX_VencControl.c
 * @brief
 * @author      SeungBeom Kim (sbcrux.kim@samsung.com)
 * @version     2.0.0
 * @history
 *   2012.02.20 : Create
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Exynos_OMX_Macros.h"
#include "Exynos_OSAL_Event.h"
#include "Exynos_OMX_Venc.h"
#include "Exynos_OMX_VencControl.h"
#include "Exynos_OMX_Basecomponent.h"
#include "Exynos_OSAL_Thread.h"
#include "Exynos_OSAL_Semaphore.h"
#include "Exynos_OSAL_Mutex.h"
#include "Exynos_OSAL_ETC.h"
#include "Exynos_OSAL_SharedMemory.h"

#ifdef USE_ANB
#include "Exynos_OSAL_Android.h"
#endif

#undef  EXYNOS_LOG_TAG
#define EXYNOS_LOG_TAG    "EXYNOS_VIDEO_ENCCONTROL"
#define EXYNOS_LOG_OFF
//#define EXYNOS_TRACE_ON
#include "Exynos_OSAL_Log.h"

OMX_ERRORTYPE Exynos_OMX_UseBuffer(
    OMX_IN OMX_HANDLETYPE            hComponent,
    OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
    OMX_IN OMX_U32                   nPortIndex,
    OMX_IN OMX_PTR                   pAppPrivate,
    OMX_IN OMX_U32                   nSizeBytes,
    OMX_IN OMX_U8                   *pBuffer)
{
    OMX_ERRORTYPE          ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE     *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
    EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;
    OMX_BUFFERHEADERTYPE  *temp_bufferHeader = NULL;
    OMX_U32                i = 0;

    FunctionIn();

    if (hComponent == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;

    if (nPortIndex >= pExynosComponent->portParam.nPorts) {
        ret = OMX_ErrorBadPortIndex;
        goto EXIT;
    }
    pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];

    if (pExynosPort->portState != OMX_StateIdle) {
        ret = OMX_ErrorIncorrectStateOperation;
        goto EXIT;
    }

    if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) {
        ret = OMX_ErrorBadPortIndex;
        goto EXIT;
    }

    temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
    if (temp_bufferHeader == NULL) {
        ret = OMX_ErrorInsufficientResources;
        goto EXIT;
    }
    Exynos_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));

    for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) {
        if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
            pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
            pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
            INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
            temp_bufferHeader->pBuffer        = pBuffer;
            temp_bufferHeader->nAllocLen      = nSizeBytes;
            temp_bufferHeader->pAppPrivate    = pAppPrivate;
            if (nPortIndex == INPUT_PORT_INDEX)
                temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
            else
                temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;

            pExynosPort->assignedBufferNum++;
            if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) {
                pExynosPort->portDefinition.bPopulated = OMX_TRUE;
                /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
                Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource);
                /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
            }
            *ppBufferHdr = temp_bufferHeader;
            ret = OMX_ErrorNone;
            goto EXIT;
        }
    }

    Exynos_OSAL_Free(temp_bufferHeader);
    ret = OMX_ErrorInsufficientResources;

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_AllocateBuffer(
    OMX_IN OMX_HANDLETYPE            hComponent,
    OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
    OMX_IN OMX_U32                   nPortIndex,
    OMX_IN OMX_PTR                   pAppPrivate,
    OMX_IN OMX_U32                   nSizeBytes)
{
    OMX_ERRORTYPE          ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE     *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
    EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
    EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;
    OMX_BUFFERHEADERTYPE  *temp_bufferHeader = NULL;
    OMX_U8                *temp_buffer = NULL;
    int                    temp_buffer_fd = -1;
    OMX_U32                i = 0;
    MEMORY_TYPE            mem_type;

    FunctionIn();

    if (hComponent == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;

    if (nPortIndex >= pExynosComponent->portParam.nPorts) {
        ret = OMX_ErrorBadPortIndex;
        goto EXIT;
    }
    pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
/*
    if (pExynosPort->portState != OMX_StateIdle ) {
        ret = OMX_ErrorIncorrectStateOperation;
        goto EXIT;
    }
*/
    if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) {
        ret = OMX_ErrorBadPortIndex;
        goto EXIT;
    }

    if (pExynosPort->bufferProcessType == BUFFER_SHARE) {
        mem_type = NORMAL_MEMORY;
    } else {
        mem_type = SYSTEM_MEMORY;
    }
    temp_buffer = Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, nSizeBytes, mem_type);
    if (temp_buffer == NULL) {
        ret = OMX_ErrorInsufficientResources;
        goto EXIT;
    }
    temp_buffer_fd = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, temp_buffer);

    temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
    if (temp_bufferHeader == NULL) {
        Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, temp_buffer);
        ret = OMX_ErrorInsufficientResources;
        goto EXIT;
    }
    Exynos_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));

    for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) {
        if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
            pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
            pExynosPort->extendBufferHeader[i].buf_fd[0] = temp_buffer_fd;
            pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED);
            INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
            temp_bufferHeader->pBuffer        = temp_buffer;
            temp_bufferHeader->nAllocLen      = nSizeBytes;
            temp_bufferHeader->pAppPrivate    = pAppPrivate;
            if (nPortIndex == INPUT_PORT_INDEX)
                temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
            else
                temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
            pExynosPort->assignedBufferNum++;
            if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) {
                pExynosPort->portDefinition.bPopulated = OMX_TRUE;
                /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
                Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource);
                /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
            }
            *ppBuffer = temp_bufferHeader;
            ret = OMX_ErrorNone;
            goto EXIT;
        }
    }

    Exynos_OSAL_Free(temp_bufferHeader);
    Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, temp_buffer);

    ret = OMX_ErrorInsufficientResources;

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_FreeBuffer(
    OMX_IN OMX_HANDLETYPE hComponent,
    OMX_IN OMX_U32        nPortIndex,
    OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr)
{
    OMX_ERRORTYPE          ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE     *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
    EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
    EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;
    OMX_BUFFERHEADERTYPE  *temp_bufferHeader = NULL;
    OMX_U8                *temp_buffer = NULL;
    OMX_U32                i = 0;

    FunctionIn();

    if (hComponent == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;

    if (nPortIndex >= pExynosComponent->portParam.nPorts) {
        ret = OMX_ErrorBadPortIndex;
        goto EXIT;
    }
    pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];

    if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) {
        ret = OMX_ErrorBadPortIndex;
        goto EXIT;
    }

    if ((pExynosPort->portState != OMX_StateLoaded) && (pExynosPort->portState != OMX_StateInvalid)) {
        (*(pExynosComponent->pCallbacks->EventHandler)) (pOMXComponent,
                        pExynosComponent->callbackData,
                        (OMX_U32)OMX_EventError,
                        (OMX_U32)OMX_ErrorPortUnpopulated,
                        nPortIndex, NULL);
    }

    for (i = 0; i < /*pExynosPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) {
        if (((pExynosPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pExynosPort->extendBufferHeader[i].OMXBufferHeader != NULL)) {
            if (pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer == pBufferHdr->pBuffer) {
                if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) {
                    Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
                    pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer = NULL;
                    pBufferHdr->pBuffer = NULL;
                } else if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) {
                    ; /* None*/
                }
                pExynosPort->assignedBufferNum--;
                if (pExynosPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) {
                    Exynos_OSAL_Free(pExynosPort->extendBufferHeader[i].OMXBufferHeader);
                    pExynosPort->extendBufferHeader[i].OMXBufferHeader = NULL;
                    pBufferHdr = NULL;
                }
                pExynosPort->bufferStateAllocate[i] = BUFFER_STATE_FREE;
                ret = OMX_ErrorNone;
                goto EXIT;
            }
        }
    }

EXIT:
    if (ret == OMX_ErrorNone) {
        if (pExynosPort->assignedBufferNum == 0) {
            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosPort->unloadedResource signal set");
            /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
            Exynos_OSAL_SemaphorePost(pExynosPort->unloadedResource);
            /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
            pExynosPort->portDefinition.bPopulated = OMX_FALSE;
        }
    }

    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_AllocateTunnelBuffer(EXYNOS_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
{
    OMX_ERRORTYPE                 ret = OMX_ErrorNone;
    EXYNOS_OMX_BASEPORT             *pExynosPort = NULL;
    OMX_BUFFERHEADERTYPE         *temp_bufferHeader = NULL;
    OMX_U8                       *temp_buffer = NULL;
    OMX_U32                       bufferSize = 0;
    OMX_PARAM_PORTDEFINITIONTYPE  portDefinition;

    ret = OMX_ErrorTunnelingUnsupported;
EXIT:
    return ret;
}

OMX_ERRORTYPE Exynos_OMX_FreeTunnelBuffer(EXYNOS_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;
    EXYNOS_OMX_BASEPORT* pExynosPort = NULL;
    OMX_BUFFERHEADERTYPE* temp_bufferHeader = NULL;
    OMX_U8 *temp_buffer = NULL;
    OMX_U32 bufferSize = 0;

    ret = OMX_ErrorTunnelingUnsupported;
EXIT:
    return ret;
}

OMX_ERRORTYPE Exynos_OMX_ComponentTunnelRequest(
    OMX_IN OMX_HANDLETYPE hComp,
    OMX_IN OMX_U32        nPort,
    OMX_IN OMX_HANDLETYPE hTunneledComp,
    OMX_IN OMX_U32        nTunneledPort,
    OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    ret = OMX_ErrorTunnelingUnsupported;
EXIT:
    return ret;
}

OMX_ERRORTYPE Exynos_OMX_GetFlushBuffer(EXYNOS_OMX_BASEPORT *pExynosPort, EXYNOS_OMX_DATABUFFER *pDataBuffer[])
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    FunctionIn();

    *pDataBuffer = NULL;

    if (pExynosPort->portWayType == WAY1_PORT) {
        *pDataBuffer = &pExynosPort->way.port1WayDataBuffer.dataBuffer;
    } else if (pExynosPort->portWayType == WAY2_PORT) {
            pDataBuffer[0] = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);
            pDataBuffer[1] = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer);
    }

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex)
{
    OMX_ERRORTYPE          ret = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;
    OMX_BUFFERHEADERTYPE     *bufferHeader = NULL;
    EXYNOS_OMX_DATABUFFER    *pDataPortBuffer[2] = {NULL, NULL};
    EXYNOS_OMX_MESSAGE       *message = NULL;
    OMX_U32                flushNum = 0;
    OMX_S32                semValue = 0;
    int i = 0, maxBufferNum = 0;
    FunctionIn();

    pExynosPort = &pExynosComponent->pExynosPort[portIndex];

    while (Exynos_OSAL_GetElemNum(&pExynosPort->bufferQ) > 0) {
        Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[portIndex].bufferSemID, &semValue);
        if (semValue == 0)
            Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[portIndex].bufferSemID);

        Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[portIndex].bufferSemID);
        message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
        if ((message != NULL) && (message->messageType != EXYNOS_OMX_CommandFakeBuffer)) {
            bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData;
            bufferHeader->nFilledLen = 0;

            if (portIndex == OUTPUT_PORT_INDEX) {
                Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
            } else if (portIndex == INPUT_PORT_INDEX) {
                Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
            }
        }
        Exynos_OSAL_Free(message);
        message = NULL;
    }

    Exynos_OMX_GetFlushBuffer(pExynosPort, pDataPortBuffer);
    if (portIndex == INPUT_PORT_INDEX) {
        if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
            Exynos_InputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
        if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
            Exynos_InputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
    } else if (portIndex == OUTPUT_PORT_INDEX) {
        if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
            Exynos_OutputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
        if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
            Exynos_OutputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
    }

    if (pExynosComponent->bMultiThreadProcess == OMX_TRUE) {
        if (pExynosPort->bufferProcessType == BUFFER_SHARE) {
            if (pExynosPort->processData.bufferHeader != NULL) {
                if (portIndex == INPUT_PORT_INDEX) {
                    Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader);
                } else if (portIndex == OUTPUT_PORT_INDEX) {
                    Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader);
                }
            }
            Exynos_ResetCodecData(&pExynosPort->processData);

            maxBufferNum = pExynosPort->portDefinition.nBufferCountActual;
            for (i = 0; i < maxBufferNum; i++) {
                if (pExynosPort->extendBufferHeader[i].bBufferInOMX == OMX_TRUE) {
                    if (portIndex == OUTPUT_PORT_INDEX) {
                        Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader);
                    } else if (portIndex == INPUT_PORT_INDEX) {
                        Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader);
                    }
                }
            }
        }
    } else {
        Exynos_ResetCodecData(&pExynosPort->processData);
    }

    while(1) {
        OMX_S32 cnt = 0;
        Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[portIndex].bufferSemID, &cnt);
        if (cnt <= 0)
            break;
        Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[portIndex].bufferSemID);
    }
    Exynos_OSAL_ResetQueue(&pExynosPort->bufferQ);

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent)
{
    OMX_ERRORTYPE             ret = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
    EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
    EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;
    EXYNOS_OMX_DATABUFFER    *flushPortBuffer[2] = {NULL, NULL};
    OMX_U32                   i = 0, cnt = 0;

    FunctionIn();

    if (pOMXComponent == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;

    Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush start, port:%d", nPortIndex);

    pExynosComponent->pExynosPort[nPortIndex].bIsPortFlushed = OMX_TRUE;

    if (pExynosComponent->bMultiThreadProcess == OMX_FALSE) {
        Exynos_OSAL_SignalSet(pExynosComponent->pauseEvent);
    } else {
        Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[nPortIndex].pauseEvent);
    }

    pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
    Exynos_OMX_GetFlushBuffer(pExynosPort, flushPortBuffer);

    if ((pExynosComponent->pExynosPort[nPortIndex].bufferProcessType & BUFFER_COPY) == BUFFER_COPY)
        Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID);
    Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID);

    pVideoEnc->exynos_codec_bufferProcessRun(pOMXComponent, nPortIndex);
    Exynos_OSAL_MutexLock(flushPortBuffer[0]->bufferMutex);
    pVideoEnc->exynos_codec_stop(pOMXComponent, nPortIndex);
    Exynos_OSAL_MutexLock(flushPortBuffer[1]->bufferMutex);
    ret = Exynos_OMX_FlushPort(pOMXComponent, nPortIndex);
    if ((pExynosComponent->pExynosPort[nPortIndex].bufferProcessType & BUFFER_COPY) == BUFFER_COPY)
        pVideoEnc->exynos_codec_enqueueAllBuffer(pOMXComponent, nPortIndex);
    Exynos_ResetCodecData(&pExynosPort->processData);

    if (ret == OMX_ErrorNone) {
        if (nPortIndex == INPUT_PORT_INDEX) {
            pExynosComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
            pExynosComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
            Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
            Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
            pExynosComponent->getAllDelayBuffer = OMX_FALSE;
            pExynosComponent->bSaveFlagEOS = OMX_FALSE;
            pExynosComponent->bBehaviorEOS = OMX_FALSE;
            pExynosComponent->reInputData = OMX_FALSE;
        }

        pExynosComponent->pExynosPort[nPortIndex].bIsPortFlushed = OMX_FALSE;
        Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush EventCmdComplete, port:%d", nPortIndex);
        if (bEvent == OMX_TRUE)
            pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
                            pExynosComponent->callbackData,
                            OMX_EventCmdComplete,
                            OMX_CommandFlush, nPortIndex, NULL);
    }
    Exynos_OSAL_MutexUnlock(flushPortBuffer[1]->bufferMutex);
    Exynos_OSAL_MutexUnlock(flushPortBuffer[0]->bufferMutex);

EXIT:
    if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pExynosComponent != NULL)) {
        Exynos_OSAL_Log(EXYNOS_LOG_ERROR,"%s : %d", __FUNCTION__, __LINE__);
        pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
                        pExynosComponent->callbackData,
                        OMX_EventError,
                        ret, 0, NULL);
    }

    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer)
{
    OMX_ERRORTYPE          ret = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    EXYNOS_OMX_BASEPORT      *exynosOMXInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
    OMX_BUFFERHEADERTYPE  *bufferHeader = NULL;

    FunctionIn();

    bufferHeader = dataBuffer->bufferHeader;

    if (bufferHeader != NULL) {
        if (exynosOMXInputPort->markType.hMarkTargetComponent != NULL ) {
            bufferHeader->hMarkTargetComponent      = exynosOMXInputPort->markType.hMarkTargetComponent;
            bufferHeader->pMarkData                 = exynosOMXInputPort->markType.pMarkData;
            exynosOMXInputPort->markType.hMarkTargetComponent = NULL;
            exynosOMXInputPort->markType.pMarkData = NULL;
        }

        if (bufferHeader->hMarkTargetComponent != NULL) {
            if (bufferHeader->hMarkTargetComponent == pOMXComponent) {
                pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
                                pExynosComponent->callbackData,
                                OMX_EventMark,
                                0, 0, bufferHeader->pMarkData);
            } else {
                pExynosComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent;
                pExynosComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData;
            }
        }

        bufferHeader->nFilledLen = 0;
        bufferHeader->nOffset = 0;
        Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
    }

    /* reset dataBuffer */
    Exynos_ResetDataBuffer(dataBuffer);

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_InputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
{
    OMX_ERRORTYPE          ret = OMX_ErrorUndefined;
    EXYNOS_OMX_BASEPORT   *pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
    EXYNOS_OMX_MESSAGE    *message = NULL;
    EXYNOS_OMX_DATABUFFER *inputUseBuffer = NULL;

    FunctionIn();

    inputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);

    if (pExynosComponent->currentState != OMX_StateExecuting) {
        ret = OMX_ErrorUndefined;
        goto EXIT;
    } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
               (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) {
        Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);
        if (inputUseBuffer->dataValid != OMX_TRUE) {
            message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
            if (message == NULL) {
                ret = OMX_ErrorUndefined;
                goto EXIT;
            }
            if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
                Exynos_OSAL_Free(message);
                ret = OMX_ErrorCodecFlush;
                goto EXIT;
            }

            inputUseBuffer->bufferHeader  = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
            inputUseBuffer->allocSize     = inputUseBuffer->bufferHeader->nAllocLen;
            inputUseBuffer->dataLen       = inputUseBuffer->bufferHeader->nFilledLen;
            inputUseBuffer->remainDataLen = inputUseBuffer->dataLen;
            inputUseBuffer->usedDataLen   = 0;
            inputUseBuffer->dataValid     = OMX_TRUE;
            inputUseBuffer->nFlags        = inputUseBuffer->bufferHeader->nFlags;
            inputUseBuffer->timeStamp     = inputUseBuffer->bufferHeader->nTimeStamp;

            Exynos_OSAL_Free(message);

            if (inputUseBuffer->allocSize <= inputUseBuffer->dataLen)
                Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", inputUseBuffer->allocSize, inputUseBuffer->dataLen);
        }
        ret = OMX_ErrorNone;
    }
EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer)
{
    OMX_ERRORTYPE          ret = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    EXYNOS_OMX_BASEPORT      *exynosOMXOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
    OMX_BUFFERHEADERTYPE  *bufferHeader = NULL;

    FunctionIn();

    bufferHeader = dataBuffer->bufferHeader;

    if (bufferHeader != NULL) {
        bufferHeader->nFilledLen = dataBuffer->remainDataLen;
        bufferHeader->nOffset    = 0;
        bufferHeader->nFlags     = dataBuffer->nFlags;
        bufferHeader->nTimeStamp = dataBuffer->timeStamp;

        if (pExynosComponent->propagateMarkType.hMarkTargetComponent != NULL) {
            bufferHeader->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent;
            bufferHeader->pMarkData = pExynosComponent->propagateMarkType.pMarkData;
            pExynosComponent->propagateMarkType.hMarkTargetComponent = NULL;
            pExynosComponent->propagateMarkType.pMarkData = NULL;
        }

        if ((bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
            Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"event OMX_BUFFERFLAG_EOS!!!");
            pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
                            pExynosComponent->callbackData,
                            OMX_EventBufferFlag,
                            OUTPUT_PORT_INDEX,
                            bufferHeader->nFlags, NULL);
        }

        Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
    }

    /* reset dataBuffer */
    Exynos_ResetDataBuffer(dataBuffer);

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OutputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
{
    OMX_ERRORTYPE       ret = OMX_ErrorUndefined;
    EXYNOS_OMX_BASEPORT   *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
    EXYNOS_OMX_MESSAGE    *message = NULL;
    EXYNOS_OMX_DATABUFFER *outputUseBuffer = NULL;

    FunctionIn();

    if ((pExynosPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) {
        outputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer);
    } else if (pExynosPort->bufferProcessType == BUFFER_SHARE) {
        outputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);
    }

    if (pExynosComponent->currentState != OMX_StateExecuting) {
        ret = OMX_ErrorUndefined;
        goto EXIT;
    } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
               (!CHECK_PORT_BEING_FLUSHED(pExynosPort))){
        Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);
        if (outputUseBuffer->dataValid != OMX_TRUE) {
            message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
            if (message == NULL) {
                ret = OMX_ErrorUndefined;
                goto EXIT;
            }
            if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
                Exynos_OSAL_Free(message);
                ret = OMX_ErrorCodecFlush;
                goto EXIT;
            }

            outputUseBuffer->bufferHeader  = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
            outputUseBuffer->allocSize     = outputUseBuffer->bufferHeader->nAllocLen;
            outputUseBuffer->dataLen       = 0; //dataBuffer->bufferHeader->nFilledLen;
            outputUseBuffer->remainDataLen = outputUseBuffer->dataLen;
            outputUseBuffer->usedDataLen   = 0; //dataBuffer->bufferHeader->nOffset;
            outputUseBuffer->dataValid     = OMX_TRUE;
            /* dataBuffer->nFlags             = dataBuffer->bufferHeader->nFlags; */
            /* dataBuffer->nTimeStamp         = dataBuffer->bufferHeader->nTimeStamp; */
/*
            if (pExynosPort->bufferProcessType == BUFFER_SHARE)
                outputUseBuffer->pPrivate      = outputUseBuffer->bufferHeader->pOutputPortPrivate;
            else if ((pExynosPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) {
                pExynosPort->processData.dataBuffer = outputUseBuffer->bufferHeader->pBuffer;
                pExynosPort->processData.allocSize  = outputUseBuffer->bufferHeader->nAllocLen;
            }
*/

            Exynos_OSAL_Free(message);
        }
        ret = OMX_ErrorNone;
    }
EXIT:
    FunctionOut();

    return ret;

}

OMX_BUFFERHEADERTYPE *Exynos_OutputBufferGetQueue_Direct(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
{
    OMX_BUFFERHEADERTYPE  *retBuffer = NULL;
    EXYNOS_OMX_BASEPORT   *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
    EXYNOS_OMX_MESSAGE    *message = NULL;

    FunctionIn();

    if (pExynosComponent->currentState != OMX_StateExecuting) {
        retBuffer = NULL;
        goto EXIT;
    } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
               (!CHECK_PORT_BEING_FLUSHED(pExynosPort))){
        Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);

        message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
        if (message == NULL) {
            retBuffer = NULL;
            goto EXIT;
        }
        if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
            Exynos_OSAL_Free(message);
            retBuffer = NULL;
            goto EXIT;
        }

        retBuffer  = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
        Exynos_OSAL_Free(message);
    }

EXIT:
    FunctionOut();

    return retBuffer;
}

OMX_ERRORTYPE Exynos_CodecBufferEnQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex, OMX_PTR data)
{
    OMX_ERRORTYPE       ret = OMX_ErrorNone;
    EXYNOS_OMX_BASEPORT   *pExynosPort = NULL;

    FunctionIn();

    pExynosPort= &pExynosComponent->pExynosPort[PortIndex];

    if (data == NULL) {
        ret = OMX_ErrorInsufficientResources;
        goto EXIT;
    }

    ret = Exynos_OSAL_Queue(&pExynosPort->codecBufferQ, (void *)data);
    if (ret != 0) {
        ret = OMX_ErrorUndefined;
        goto EXIT;
    }
    Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID);

    ret = OMX_ErrorNone;

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_CodecBufferDeQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex, OMX_PTR *data)
{
    OMX_ERRORTYPE       ret = OMX_ErrorNone;
    EXYNOS_OMX_BASEPORT   *pExynosPort = NULL;
    OMX_U32 tempData;

    FunctionIn();

    pExynosPort = &pExynosComponent->pExynosPort[PortIndex];
    Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID);
    tempData = (OMX_U32)Exynos_OSAL_Dequeue(&pExynosPort->codecBufferQ);
    if (tempData == NULL) {
        *data = NULL;
        ret = OMX_ErrorUndefined;
        goto EXIT;
    }
    *data = (OMX_PTR)tempData;

    ret = OMX_ErrorNone;

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_CodecBufferReset(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex)
{
    OMX_ERRORTYPE       ret = OMX_ErrorNone;
    EXYNOS_OMX_BASEPORT   *pExynosPort = NULL;

    FunctionIn();

    pExynosPort= &pExynosComponent->pExynosPort[PortIndex];

    ret = Exynos_OSAL_ResetQueue(&pExynosPort->codecBufferQ);
    if (ret != 0) {
        ret = OMX_ErrorUndefined;
        goto EXIT;
    }
    while (1) {
        int cnt = 0;
        Exynos_OSAL_Get_SemaphoreCount(pExynosPort->codecSemID, &cnt);
        if (cnt > 0)
            Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID);
        else
            break;
    }
    ret = OMX_ErrorNone;

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetParameter(
    OMX_IN OMX_HANDLETYPE hComponent,
    OMX_IN OMX_INDEXTYPE  nParamIndex,
    OMX_INOUT OMX_PTR     ComponentParameterStructure)
{
    OMX_ERRORTYPE             ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE        *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
    EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;

    FunctionIn();

    if (hComponent == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;

    if (pExynosComponent->currentState == OMX_StateInvalid ) {
        ret = OMX_ErrorInvalidState;
        goto EXIT;
    }

    if (ComponentParameterStructure == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }

    switch (nParamIndex) {
    case OMX_IndexParamVideoInit:
    {
        OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
        ret = Exynos_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE));
        if (ret != OMX_ErrorNone) {
            goto EXIT;
        }

        portParam->nPorts           = pExynosComponent->portParam.nPorts;
        portParam->nStartPortNumber = pExynosComponent->portParam.nStartPortNumber;
        ret = OMX_ErrorNone;
    }
        break;
    case OMX_IndexParamVideoPortFormat:
    {
        OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
        OMX_U32                         portIndex = portFormat->nPortIndex;
        OMX_U32                         index    = portFormat->nIndex;
        EXYNOS_OMX_BASEPORT            *pExynosPort = NULL;
        OMX_PARAM_PORTDEFINITIONTYPE   *portDefinition = NULL;
        OMX_U32                         supportFormatNum = 0;

        ret = Exynos_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
        if (ret != OMX_ErrorNone) {
            goto EXIT;
        }

        if ((portIndex >= pExynosComponent->portParam.nPorts)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        }

        if (portIndex == INPUT_PORT_INDEX) {
            pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
            portDefinition = &pExynosPort->portDefinition;

            switch (index) {
            case supportFormat_0:
                portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
                portFormat->eColorFormat       = OMX_COLOR_FormatYUV420Planar;
                portFormat->xFramerate           = portDefinition->format.video.xFramerate;
                break;
            case supportFormat_1:
                portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
                portFormat->eColorFormat       = OMX_COLOR_FormatYUV420SemiPlanar;
                portFormat->xFramerate         = portDefinition->format.video.xFramerate;
                break;
            case supportFormat_2:
                portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
                portFormat->eColorFormat       = OMX_SEC_COLOR_FormatNV12Tiled;
                portFormat->xFramerate         = portDefinition->format.video.xFramerate;
                break;
            case supportFormat_3:
                portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
                portFormat->eColorFormat       = OMX_SEC_COLOR_FormatNV21Linear;
                portFormat->xFramerate         = portDefinition->format.video.xFramerate;
                break;
            case supportFormat_4:
                portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
                portFormat->eColorFormat       = OMX_COLOR_FormatAndroidOpaque;
                portFormat->xFramerate         = portDefinition->format.video.xFramerate;
                break;
            default:
                if (index > supportFormat_0) {
                    ret = OMX_ErrorNoMore;
                    goto EXIT;
                }
                break;
            }
        } else if (portIndex == OUTPUT_PORT_INDEX) {
            supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1;
            if (index > supportFormatNum) {
                ret = OMX_ErrorNoMore;
                goto EXIT;
            }

            pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
            portDefinition = &pExynosPort->portDefinition;

            portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat;
            portFormat->eColorFormat       = portDefinition->format.video.eColorFormat;
            portFormat->xFramerate         = portDefinition->format.video.xFramerate;
        }
        ret = OMX_ErrorNone;
    }
        break;
    case OMX_IndexParamVideoBitrate:
    {
        OMX_VIDEO_PARAM_BITRATETYPE     *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure;
        OMX_U32                          portIndex = videoRateControl->nPortIndex;
        EXYNOS_OMX_BASEPORT             *pExynosPort = NULL;
        EXYNOS_OMX_VIDEOENC_COMPONENT   *pVideoEnc = NULL;
        OMX_PARAM_PORTDEFINITIONTYPE    *portDefinition = NULL;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            portDefinition = &pExynosPort->portDefinition;

            videoRateControl->eControlRate = pVideoEnc->eControlRate[portIndex];
            videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate;
        }
        ret = OMX_ErrorNone;
    }
        break;
    case OMX_IndexParamVideoQuantization:
    {
        OMX_VIDEO_PARAM_QUANTIZATIONTYPE  *videoQuantizationControl = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)ComponentParameterStructure;
        OMX_U32                            portIndex = videoQuantizationControl->nPortIndex;
        EXYNOS_OMX_BASEPORT               *pExynosPort = NULL;
        EXYNOS_OMX_VIDEOENC_COMPONENT     *pVideoEnc = NULL;
        OMX_PARAM_PORTDEFINITIONTYPE      *portDefinition = NULL;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            portDefinition = &pExynosPort->portDefinition;

            videoQuantizationControl->nQpI = pVideoEnc->quantization.nQpI;
            videoQuantizationControl->nQpP = pVideoEnc->quantization.nQpP;
            videoQuantizationControl->nQpB = pVideoEnc->quantization.nQpB;
        }
        ret = OMX_ErrorNone;
    }
        break;
    case OMX_IndexParamPortDefinition:
    {
        OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
        OMX_U32                       portIndex = portDefinition->nPortIndex;
        EXYNOS_OMX_BASEPORT          *pExynosPort;

        if (portIndex >= pExynosComponent->portParam.nPorts) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        }
        ret = Exynos_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
        if (ret != OMX_ErrorNone) {
            goto EXIT;
        }

        pExynosPort = &pExynosComponent->pExynosPort[portIndex];
        Exynos_OSAL_Memcpy(portDefinition, &pExynosPort->portDefinition, portDefinition->nSize);

#ifdef USE_STOREMETADATA
        if ((portIndex == 0) && (pExynosPort->bStoreMetaData == OMX_TRUE)) {
            portDefinition->nBufferSize = MAX_INPUT_METADATA_BUFFER_SIZE;
        }
#endif
    }
        break;
    case OMX_IndexParamVideoIntraRefresh:
    {
        OMX_VIDEO_PARAM_INTRAREFRESHTYPE *pIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)ComponentParameterStructure;
        OMX_U32                           portIndex = pIntraRefresh->nPortIndex;
        EXYNOS_OMX_VIDEOENC_COMPONENT    *pVideoEnc = NULL;

        if (portIndex != OUTPUT_PORT_INDEX) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
            pIntraRefresh->eRefreshMode = pVideoEnc->intraRefresh.eRefreshMode;
            pIntraRefresh->nAirMBs = pVideoEnc->intraRefresh.nAirMBs;
            pIntraRefresh->nAirRef = pVideoEnc->intraRefresh.nAirRef;
            pIntraRefresh->nCirMBs = pVideoEnc->intraRefresh.nCirMBs;
        }
        ret = OMX_ErrorNone;
    }
        break;
    default:
    {
        ret = Exynos_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
    }
        break;
    }

EXIT:
    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetParameter(
    OMX_IN OMX_HANDLETYPE hComponent,
    OMX_IN OMX_INDEXTYPE  nIndex,
    OMX_IN OMX_PTR        ComponentParameterStructure)
{
    OMX_ERRORTYPE             ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE        *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
    EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;

    FunctionIn();

    if (hComponent == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;

    if (pExynosComponent->currentState == OMX_StateInvalid ) {
        ret = OMX_ErrorInvalidState;
        goto EXIT;
    }

    if (ComponentParameterStructure == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }

    switch (nIndex) {
    case OMX_IndexParamVideoPortFormat:
    {
        OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
        OMX_U32                         portIndex = portFormat->nPortIndex;
        OMX_U32                         index    = portFormat->nIndex;
        EXYNOS_OMX_BASEPORT            *pExynosPort = NULL;
        OMX_PARAM_PORTDEFINITIONTYPE   *portDefinition = NULL;
        OMX_U32                         supportFormatNum = 0;

        ret = Exynos_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
        if (ret != OMX_ErrorNone) {
            goto EXIT;
        }

        if ((portIndex >= pExynosComponent->portParam.nPorts)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            portDefinition = &pExynosPort->portDefinition;

            portDefinition->format.video.eColorFormat       = portFormat->eColorFormat;
            portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat;
            portDefinition->format.video.xFramerate         = portFormat->xFramerate;
        }
    }
        break;
    case OMX_IndexParamVideoBitrate:
    {
        OMX_VIDEO_PARAM_BITRATETYPE     *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure;
        OMX_U32                          portIndex = videoRateControl->nPortIndex;
        EXYNOS_OMX_BASEPORT             *pExynosPort = NULL;
        EXYNOS_OMX_VIDEOENC_COMPONENT   *pVideoEnc = NULL;
        OMX_PARAM_PORTDEFINITIONTYPE    *portDefinition = NULL;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            portDefinition = &pExynosPort->portDefinition;

            pVideoEnc->eControlRate[portIndex] = videoRateControl->eControlRate;
            portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate;
        }
        ret = OMX_ErrorNone;
    }
        break;
    case OMX_IndexParamVideoQuantization:
    {
        OMX_VIDEO_PARAM_QUANTIZATIONTYPE *videoQuantizationControl = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)ComponentParameterStructure;
        OMX_U32                           portIndex = videoQuantizationControl->nPortIndex;
        EXYNOS_OMX_BASEPORT              *pExynosPort = NULL;
        EXYNOS_OMX_VIDEOENC_COMPONENT    *pVideoEnc = NULL;
        OMX_PARAM_PORTDEFINITIONTYPE     *portDefinition = NULL;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            portDefinition = &pExynosPort->portDefinition;

            pVideoEnc->quantization.nQpI = videoQuantizationControl->nQpI;
            pVideoEnc->quantization.nQpP = videoQuantizationControl->nQpP;
            pVideoEnc->quantization.nQpB = videoQuantizationControl->nQpB;
        }
        ret = OMX_ErrorNone;
    }
        break;
    case OMX_IndexParamPortDefinition:
    {
        OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
        OMX_U32                       portIndex = pPortDefinition->nPortIndex;
        EXYNOS_OMX_BASEPORT          *pExynosPort;
        OMX_U32 width, height, size;

        if (portIndex >= pExynosComponent->portParam.nPorts) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        }
        ret = Exynos_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
        if (ret != OMX_ErrorNone) {
            goto EXIT;
        }

        pExynosPort = &pExynosComponent->pExynosPort[portIndex];

        if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) {
            if (pExynosPort->portDefinition.bEnabled == OMX_TRUE) {
                ret = OMX_ErrorIncorrectStateOperation;
                goto EXIT;
            }
        }
        if (pPortDefinition->nBufferCountActual < pExynosPort->portDefinition.nBufferCountMin) {
            ret = OMX_ErrorBadParameter;
            goto EXIT;
        }

        Exynos_OSAL_Memcpy(&pExynosPort->portDefinition, pPortDefinition, pPortDefinition->nSize);
        if (portIndex == INPUT_PORT_INDEX) {
            EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
            Exynos_UpdateFrameSize(pOMXComponent);
            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosOutputPort->portDefinition.nBufferSize: %d",
                            pExynosOutputPort->portDefinition.nBufferSize);
        }
        ret = OMX_ErrorNone;
    }
        break;
    case OMX_IndexParamVideoIntraRefresh:
    {
        OMX_VIDEO_PARAM_INTRAREFRESHTYPE *pIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)ComponentParameterStructure;
        OMX_U32                           portIndex = pIntraRefresh->nPortIndex;
        EXYNOS_OMX_VIDEOENC_COMPONENT    *pVideoEnc = NULL;

        if (portIndex != OUTPUT_PORT_INDEX) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
            if (pIntraRefresh->eRefreshMode == OMX_VIDEO_IntraRefreshCyclic) {
                pVideoEnc->intraRefresh.eRefreshMode = pIntraRefresh->eRefreshMode;
                pVideoEnc->intraRefresh.nCirMBs = pIntraRefresh->nCirMBs;
                Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "OMX_VIDEO_IntraRefreshCyclic Enable, nCirMBs: %d",
                                pVideoEnc->intraRefresh.nCirMBs);
            } else {
                ret = OMX_ErrorUnsupportedSetting;
                goto EXIT;
            }
        }
        ret = OMX_ErrorNone;
    }
        break;
#ifdef USE_STOREMETADATA
    case OMX_IndexParamStoreMetaDataBuffer:
    {
        ret = Exynos_OSAL_SetANBParameter(hComponent, nIndex, ComponentParameterStructure);
    }
        break;
#endif
    default:
    {
        ret = Exynos_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
    }
        break;
    }

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetConfig(
    OMX_HANDLETYPE hComponent,
    OMX_INDEXTYPE nIndex,
    OMX_PTR pComponentConfigStructure)
{
    OMX_ERRORTYPE             ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE        *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;

    FunctionIn();

    if (hComponent == NULL || pComponentConfigStructure == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }
    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    if (pExynosComponent->currentState == OMX_StateInvalid) {
        ret = OMX_ErrorInvalidState;
        goto EXIT;
    }

    switch (nIndex) {
    case OMX_IndexConfigVideoBitrate:
    {
        OMX_VIDEO_CONFIG_BITRATETYPE *pEncodeBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure;
        OMX_U32                       portIndex = pEncodeBitrate->nPortIndex;
        EXYNOS_OMX_BASEPORT          *pExynosPort = NULL;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            pEncodeBitrate->nEncodeBitrate = pExynosPort->portDefinition.format.video.nBitrate;
        }
    }
        break;
    case OMX_IndexConfigVideoFramerate:
    {
        OMX_CONFIG_FRAMERATETYPE *pFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure;
        OMX_U32                   portIndex = pFramerate->nPortIndex;
        EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            pFramerate->xEncodeFramerate = pExynosPort->portDefinition.format.video.xFramerate;
        }
    }
        break;
    default:
        ret = Exynos_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
        break;
    }

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetConfig(
    OMX_HANDLETYPE hComponent,
    OMX_INDEXTYPE nIndex,
    OMX_PTR pComponentConfigStructure)
    {
    OMX_ERRORTYPE             ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE        *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;

    FunctionIn();

    if (hComponent == NULL || pComponentConfigStructure == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }
    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    if (pExynosComponent->currentState == OMX_StateInvalid) {
        ret = OMX_ErrorInvalidState;
        goto EXIT;
    }

    switch (nIndex) {
    case OMX_IndexConfigVideoBitrate:
    {
        OMX_VIDEO_CONFIG_BITRATETYPE *pEncodeBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure;
        OMX_U32                       portIndex = pEncodeBitrate->nPortIndex;
        EXYNOS_OMX_BASEPORT          *pExynosPort = NULL;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            pExynosPort->portDefinition.format.video.nBitrate = pEncodeBitrate->nEncodeBitrate;
        }
    }
        break;
    case OMX_IndexConfigVideoFramerate:
    {
        OMX_CONFIG_FRAMERATETYPE *pFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure;
        OMX_U32                   portIndex = pFramerate->nPortIndex;
        EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pExynosPort = &pExynosComponent->pExynosPort[portIndex];
            pExynosPort->portDefinition.format.video.xFramerate = pFramerate->xEncodeFramerate;
        }
    }
        break;
    case OMX_IndexConfigVideoIntraVOPRefresh:
    {
        OMX_CONFIG_INTRAREFRESHVOPTYPE *pIntraRefreshVOP = (OMX_CONFIG_INTRAREFRESHVOPTYPE *)pComponentConfigStructure;
        EXYNOS_OMX_VIDEOENC_COMPONENT *pVEncBase = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle);
        OMX_U32 portIndex = pIntraRefreshVOP->nPortIndex;

        if ((portIndex != OUTPUT_PORT_INDEX)) {
            ret = OMX_ErrorBadPortIndex;
            goto EXIT;
        } else {
            pVEncBase->IntraRefreshVOP = pIntraRefreshVOP->IntraRefreshVOP;
        }
    }
        break;
    default:
        ret = Exynos_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
        break;
    }

EXIT:
    FunctionOut();

    return ret;
}

OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetExtensionIndex(
    OMX_IN OMX_HANDLETYPE  hComponent,
    OMX_IN OMX_STRING      cParameterName,
    OMX_OUT OMX_INDEXTYPE *pIndexType)
{
    OMX_ERRORTYPE             ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE        *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;

    FunctionIn();

    if (hComponent == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;

    if ((cParameterName == NULL) || (pIndexType == NULL)) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    if (pExynosComponent->currentState == OMX_StateInvalid) {
        ret = OMX_ErrorInvalidState;
        goto EXIT;
    }

#ifdef USE_STOREMETADATA
    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) {
        *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamStoreMetaDataBuffer;
    } else {
        ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
    }
#else
    ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
#endif

EXIT:
    FunctionOut();

    return ret;
}