Just to make things clear
0) yes I agree I violated GLP and I feel sorry, but I didnt do it on purpose (and to be fair I didnt know much licensing details till the week I was noticed about my violation)
1) After Kieran left the comment about violation I made repo private (to spend some time to understand all details) and today I fully removed the repo
2) To be fair its easy to see it wasn’t done on purpose as I never posted updates even though the posted version had interlaced coding bug. I was asked a couple of times privately to make a custom build with my encoder and I rejected it as the only purpose I persued was to show encoder exists and performs well
3) Why dont I disclose source codes?
3.1) I was going to re-work prores_ks or add one more encoder and I had an exact plan on how to do it and I started with it. I sent couple patches 1st was approved 2nd still under review. I decided to not wait forever and Im not the one to ping every day/week to make it pushed (I believe if the community needs something it will be pushed, and its easy to prove with my mxf op1b research when my changes were pushed even though Ive never sent that patch)
3.2) I still was interested to finish my Prores encoder so I continued to work on it. And now when encoder done I plan to make a product based on it. It will be free but probably close-sourced.
3.3) Even if I want one day to make it part of ffmpeg it wont be easy to do, as my implementation done in C++ and ffmpeg is C
3.4) so the build I shared (and later removed) literally a bag of tricks.
3.5) so when Kieran/Martin/Carl or whoever says I should share prores_amcdx_encoder I can easily do it, but what will you see here? as its basically skeleton copied from prores_anatoly with whole logic replaced by calling functions from private static library
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "profiles.h"
#include "prores_defs.hpp"
#define DEFAULT_SLICE_MB_WIDTH 8
static const AVProfile profiles[] = {
{ FF_PROFILE_PRORES_PROXY, "apco"},
{ FF_PROFILE_PRORES_LT, "apcs"},
{ FF_PROFILE_PRORES_STANDARD, "apcn"},
{ FF_PROFILE_PRORES_HQ, "apch"},
{ FF_PROFILE_PRORES_4444, "ap4h"},
{ FF_PROFILE_PRORES_XQ, "ap4x"},
{ FF_PROFILE_UNKNOWN }
};
static const int valid_primaries[9] = { AVCOL_PRI_RESERVED0, AVCOL_PRI_BT709, AVCOL_PRI_UNSPECIFIED, AVCOL_PRI_BT470BG,
AVCOL_PRI_SMPTE170M, AVCOL_PRI_BT2020, AVCOL_PRI_SMPTE431, AVCOL_PRI_SMPTE432,INT_MAX };
static const int valid_trc[4] = { AVCOL_TRC_RESERVED0, AVCOL_TRC_BT709, AVCOL_TRC_UNSPECIFIED, INT_MAX };
static const int valid_colorspace[5] = { AVCOL_SPC_BT709, AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_SMPTE170M,
AVCOL_SPC_BT2020_NCL, INT_MAX };
typedef struct {
AVClass *class;
void *encoder;
int cs;
int qual;
int field_order;
int planes;
int target_size;
} ProresContext;
static int prores_encode_frame2(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
ProresContext *ctx = avctx->priv_data;
int ret;
int frame_size = amcdx_pr_encoder_encode(ctx->encoder, (void **)pict->data, (int *)pict->linesize, ctx->planes); //for the time being
if ((ret = ff_alloc_packet2(avctx, pkt, frame_size, 0)) < 0)
return ret;
amcdx_pr_encoder_read(ctx->encoder, pkt->data, &pkt->size);
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
static av_cold int prores_encode_init2(AVCodecContext *avctx)
{
ProresContext* ctx = avctx->priv_data;
avctx->bits_per_raw_sample = 10;
if (avctx->width & 0x1) {
av_log(avctx, AV_LOG_ERROR,
"frame width needs to be multiple of 2\n");
return AVERROR(EINVAL);
}
if (avctx->width > 65534 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "The maximum dimensions are 65534x65535\n");
return AVERROR(EINVAL);
}
switch (avctx->profile) {
case FF_PROFILE_UNKNOWN:
case FF_PROFILE_PRORES_STANDARD:
ctx->qual = Quality_422;
break;
case FF_PROFILE_PRORES_4444:
ctx->qual = Quality_4444;
break;
case FF_PROFILE_PRORES_HQ:
ctx->qual = Quality_422HQ;
break;
case FF_PROFILE_PRORES_LT:
ctx->qual = Quality_422LT;
break;
case FF_PROFILE_PRORES_PROXY:
ctx->qual = Quality_422Proxy;
break;
case FF_PROFILE_PRORES_XQ:
ctx->qual = Quality_4444XQ;
break;
default:
return -1;
break;
}
switch (avctx->pix_fmt) {
case AV_PIX_FMT_UYVY422:
ctx->cs = ColorSpace_uyvy;
ctx->planes = 1;
break;
case AV_PIX_FMT_YUV422P10:
ctx->cs = ColorSpace_yuv10_422_planar;
ctx->planes = 3;
break;
case AV_PIX_FMT_YUV422P12:
ctx->cs = ColorSpace_yuv12_422_planar;
ctx->planes = 3;
break;
case AV_PIX_FMT_YUV444P12:
ctx->cs = ColorSpace_yuv12_444_planar;
ctx->planes = 3;
break;
default:
break;
}
//for the time being
switch (avctx->field_order)
{
case AV_FIELD_BT:
avctx->field_order = FieldOrder_BottomFieldFirst;
break;
case AV_FIELD_TB:
avctx->field_order = FieldOrder_TopFieldFirst;
break;
case AV_FIELD_PROGRESSIVE:
default: //otherwise we think its progressive
avctx->field_order = FieldOrder_Progressive;
break;
}
ctx->encoder = amcdx_pr_encoder_create();
if (ctx->target_size != 0) {
amcdx_pr_encoder_set_frame_size(ctx->encoder, ctx->target_size);
}
avctx->codec_tag = MKTAG(profiles[avctx->profile].name[0], profiles[avctx->profile].name[1], profiles[avctx->profile].name[2], profiles[avctx->profile].name[3]);// AV_RL32((const uint8_t*)profiles[avctx->profile].name);
return amcdx_pr_encoder_init(ctx->encoder, avctx->width, avctx->height, ctx->cs, ctx->qual, ctx->field_order) - 1;
}
static av_cold int prores_encode_close2(AVCodecContext *avctx)
{
ProresContext* ctx = avctx->priv_data;
amcdx_pr_encoder_destroy(ctx->encoder);
return 0;
}
#define OFFSET(x) offsetof(ProresContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "target_size", "force frame size", OFFSET(target_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ NULL }
};
static const AVClass proresamcdx_enc_class = {
.class_name = "ProRes amcdx encoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_prores_amcdx_encoder = {
.name = "prores_amcdx",
.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PRORES,
.priv_data_size = sizeof(ProresContext),
.init = prores_encode_init2,
.close = prores_encode_close2,
.encode2 = prores_encode_frame2,
.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_UYVY422, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_NONE},
.capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY,
.priv_class = &proresamcdx_enc_class,
.profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles),
};