<commit_before>/*
 * Copyright (C) 2009-2010 <NAME>
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This file may be used under the terms of the GNU Lesser General Public
 * License version 2.1.
 */

#include "gstav_vdec.h"
#include "plugin.h"

#include <libavcodec/avcodec.h>
#include <gst/tag/tag.h>

#include <stdlib.h>
#include <string.h> /* for memcpy */
#include <stdbool.h>

#include "gstav_parse.h"

#define GST_CAT_DEFAULT gstav_debug

static GstElementClass *parent_class;

#define obj gst_av_vdec

struct obj_class {
	GstElementClass parent_class;
};

/* TODO there must be a more straight-forward way */
static GstBuffer *convert_frame(struct obj *self, AVFrame *frame)
{
	AVCodecContext *ctx;
	int i;
	GstBuffer *out_buf;
	guint8 *p;

	ctx = self->av_ctx;
	out_buf = gst_buffer_new_and_alloc(ctx->width * ctx->height * 3 / 2);
	gst_buffer_set_caps(out_buf, self->srcpad->caps);

	for (i = 0; i < ctx->height * ctx->width * 3 / 2; i++)
		out_buf->data[i] = 0;
	p = out_buf->data;
	for (i = 0; i < ctx->height; i++)
		memcpy(p + i * ctx->width, frame->data[0] + i * frame->linesize[0], ctx->width);
	p = out_buf->data + ctx->width * ctx->height;
	for (i = 0; i < ctx->height / 2; i++)
		memcpy(p + i * ctx->width / 2, frame->data[1] + i * frame->linesize[1], ctx->width / 2);
	p = out_buf->data + ctx->width * ctx->height * 5 / 4;
	for (i = 0; i < ctx->height / 2; i++)
		memcpy(p + i * ctx->width / 2, frame->data[2] + i * frame->linesize[2], ctx->width / 2);

	return out_buf;
}

static GstFlowReturn
pad_chain(GstPad *pad, GstBuffer *buf)<commit_msg>vdec: remove dead-code<commit_after>/*
 * Copyright (C) 2009-2010 <NAME>
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This file may be used under the terms of the GNU Lesser General Public
 * License version 2.1.
 */

#include "gstav_vdec.h"
#include "plugin.h"

#include <libavcodec/avcodec.h>
#include <gst/tag/tag.h>

#include <stdlib.h>
#include <string.h> /* for memcpy */
#include <stdbool.h>

#include "gstav_parse.h"

#define GST_CAT_DEFAULT gstav_debug

static GstElementClass *parent_class;

#define obj gst_av_vdec

struct obj_class {
	GstElementClass parent_class;
};

/* TODO there must be a more straight-forward way */
static GstBuffer *convert_frame(struct obj *self, AVFrame *frame)
{
	AVCodecContext *ctx;
	int i;
	GstBuffer *out_buf;
	guint8 *p;

	ctx = self->av_ctx;
	out_buf = gst_buffer_new_and_alloc(ctx->width * ctx->height * 3 / 2);
	gst_buffer_set_caps(out_buf, self->srcpad->caps);

	p = out_buf->data;
	for (i = 0; i < ctx->height; i++)
		memcpy(p + i * ctx->width, frame->data[0] + i * frame->linesize[0], ctx->width);
	p = out_buf->data + ctx->width * ctx->height;
	for (i = 0; i < ctx->height / 2; i++)
		memcpy(p + i * ctx->width / 2, frame->data[1] + i * frame->linesize[1], ctx->width / 2);
	p = out_buf->data + ctx->width * ctx->height * 5 / 4;
	for (i = 0; i < ctx->height / 2; i++)
		memcpy(p + i * ctx->width / 2, frame->data[2] + i * frame->linesize[2], ctx->width / 2);

	return out_buf;
}

static GstFlowReturn
pad_chain(GstPad *pad, GstBuffer *buf)
{'fraction_non_alphanumeric': 0.17100494233937397, 'fraction_numerical': 0.021087314662273475, 'mean_word_length': 3.8037974683544302, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2070984', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1204, 'n_words': 318}