小编dYT*_*YTe的帖子

如何正确使用 OpenH264 使用代码示例进行编码?

我有一个图像,想用OpenH264对其进行编码。

到目前为止,这是我从他们的维基派生的代码:

#include <fstream>
#include <iterator>

#include <iostream>
#include <codec_api.h> //standard api for openh264

//additional libaries used by sample code
#include <codec_app_def.h>
#include <codec_def.h>
#include <codec_ver.h>
#include <assert.h>
#include <vector>
#include <cstring>
int main()
{
  //parameter values
  int width = 1920;
  int height = 1080;
  int framerate = 60;
  int bitrate = 5000000;
  int total_num = 500; //what does this value do?
  //end parameter values

  //Read in the File from bmp
  std::vector<char> buf; //to store the …
Run Code Online (Sandbox Code Playgroud)

c++ video encoding h.264 openh264

5
推荐指数
1
解决办法
2692
查看次数

我该如何实现这种折叠功能?

给出了两种数据类型Color和Plant.

data Color = Red | Pink | White | Blue | Purple | Green | Yellow
   deriving (Show, Eq)

data Plant =
     Leaf
   | Blossom Color
   | Stalk Plant Plant
   deriving (Show, Eq)
Run Code Online (Sandbox Code Playgroud)

现在我应该实现fold_plant以下类型的功能:

(x -> x -> x) -> (Color -> x) -> x -> Plant -> x
Run Code Online (Sandbox Code Playgroud)

我理解折叠函数的方式是它需要一个列表,并且对于每次迭代,它从列表中删除第一个元素并对该元素执行某些操作.

显然fold_plant Stalk Blossom Leaf是植物的身份.

现在我知道在Haskell中你可以创建这样的函数:

fold_plant :: (x -> x -> x) -> (Color -> x) -> x -> Plant -> x
fold_plant = do …
Run Code Online (Sandbox Code Playgroud)

tree haskell fold catamorphism

4
推荐指数
1
解决办法
789
查看次数

为什么这个函数不能计算整数列表的平均值不起作用?

我正在尝试创建一个函数,它将给定列表中的所有数字相加,然后将其除以6.

average :: [Integer] -> Integer
average m = (sum m) quot 6
Run Code Online (Sandbox Code Playgroud)

但这是我收到的错误消息:

Couldn't match type `Integer'                                                                                
              with `(a0 -> a0 -> a0) -> a1 -> Integer'                                                       
Expected type: [(a0 -> a0 -> a0) -> a1 -> Integer]                                                           
  Actual type: [Integer]                                                                                     
In the first argument of `sum', namely `m'                                                                   
In the expression: (sum m) quot 6
Run Code Online (Sandbox Code Playgroud)

haskell integer average

0
推荐指数
1
解决办法
81
查看次数

如何简化此功能?

这是功能:

f []      = []
f (h:t)   = (\x -> x - h) : f t
Run Code Online (Sandbox Code Playgroud)

它接受一个列表并返回一个匿名函数列表,它们从x中减去每个元素.

显然有一些方法可以用20个字符或更少的字符写这个整个函数.

我试着这样做,map但只是将一个函数应用于列表的每个元素.我也试图替换(-a)无效的匿名函数.

有人有想法吗?

lambda haskell anonymous list haskell-prelude

0
推荐指数
1
解决办法
121
查看次数