mirror of
https://github.com/WonderfulToolchain/psxavenc.git
synced 2025-12-17 19:40:26 +00:00
Move changes over from old PR
This commit is contained in:
@@ -28,6 +28,9 @@ freely, subject to the following restrictions:
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
@@ -36,27 +39,33 @@ freely, subject to the following restrictions:
|
||||
#include <libswresample/swresample.h>
|
||||
#include <libpsxav.h>
|
||||
|
||||
#define NUM_FORMATS 9
|
||||
#define FORMAT_XA 0
|
||||
#define FORMAT_XACD 1
|
||||
#define FORMAT_SPU 2
|
||||
#define FORMAT_STR2 3
|
||||
#define FORMAT_SPUI 3
|
||||
#define FORMAT_VAG 4
|
||||
#define FORMAT_VAGI 5
|
||||
#define FORMAT_STR2 6
|
||||
#define FORMAT_STR2CD 7
|
||||
#define FORMAT_SBS2 8
|
||||
|
||||
#define MAX_UNMUXED_BLOCKS 9
|
||||
typedef struct {
|
||||
int frame_index;
|
||||
int frame_block_index;
|
||||
int frame_block_count;
|
||||
int frame_data_offset;
|
||||
int frame_max_size;
|
||||
int frame_block_base_overflow;
|
||||
int frame_block_overflow_num;
|
||||
int frame_block_overflow_den;
|
||||
uint16_t bits_value;
|
||||
int bits_left;
|
||||
uint8_t unmuxed[2016*MAX_UNMUXED_BLOCKS];
|
||||
uint8_t *frame_output;
|
||||
int bytes_used;
|
||||
int blocks_used;
|
||||
int uncomp_hwords_used;
|
||||
int quant_scale;
|
||||
int32_t *dct_block_lists[6];
|
||||
int quant_scale_sum;
|
||||
float *dct_block_lists[6];
|
||||
} vid_encoder_state_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -69,8 +78,6 @@ typedef struct {
|
||||
AVStream* video_stream;
|
||||
AVCodecContext* audio_codec_context;
|
||||
AVCodecContext* video_codec_context;
|
||||
AVCodec* audio_codec;
|
||||
AVCodec* video_codec;
|
||||
struct SwrContext* resampler;
|
||||
struct SwsContext* scaler;
|
||||
AVFrame* frame;
|
||||
@@ -81,17 +88,28 @@ typedef struct {
|
||||
} av_decoder_state_t;
|
||||
|
||||
typedef struct {
|
||||
bool quiet;
|
||||
bool show_progress;
|
||||
|
||||
int format; // FORMAT_*
|
||||
bool stereo; // false or true
|
||||
int channels;
|
||||
int cd_speed; // 1 or 2
|
||||
int frequency; // 18900 or 37800 Hz
|
||||
int bits_per_sample; // 4 or 8
|
||||
int file_number; // 00-FF
|
||||
int channel_number; // 00-1F
|
||||
int interleave;
|
||||
int alignment;
|
||||
bool loop;
|
||||
|
||||
int video_width;
|
||||
int video_height;
|
||||
int video_fps_num; // FPS numerator
|
||||
int video_fps_den; // FPS denominator
|
||||
bool ignore_aspect_ratio;
|
||||
|
||||
char *swresample_options;
|
||||
char *swscale_options;
|
||||
|
||||
int16_t *audio_samples;
|
||||
int audio_sample_count;
|
||||
@@ -99,8 +117,11 @@ typedef struct {
|
||||
int video_frame_count;
|
||||
|
||||
av_decoder_state_t decoder_state_av;
|
||||
|
||||
vid_encoder_state_t state_vid;
|
||||
bool end_of_input;
|
||||
|
||||
time_t start_time;
|
||||
time_t last_progress_update;
|
||||
} settings_t;
|
||||
|
||||
// cdrom.c
|
||||
@@ -108,17 +129,19 @@ void init_sector_buffer_video(uint8_t *buffer, settings_t *settings);
|
||||
void calculate_edc_data(uint8_t *buffer);
|
||||
|
||||
// decoding.c
|
||||
bool open_av_data(const char *filename, settings_t *settings);
|
||||
bool open_av_data(const char *filename, settings_t *settings, bool use_audio, bool use_video, bool audio_required, bool video_required);
|
||||
bool poll_av_data(settings_t *settings);
|
||||
bool ensure_av_data(settings_t *settings, int needed_audio_samples, int needed_video_frames);
|
||||
void pull_all_av_data(settings_t *settings);
|
||||
void retire_av_data(settings_t *settings, int retired_audio_samples, int retired_video_frames);
|
||||
void close_av_data(settings_t *settings);
|
||||
|
||||
// filefmt.c
|
||||
void encode_file_spu(int16_t *audio_samples, int audio_sample_count, settings_t *settings, FILE *output);
|
||||
void encode_file_xa(int16_t *audio_samples, int audio_sample_count, settings_t *settings, FILE *output);
|
||||
void encode_file_spu(settings_t *settings, FILE *output);
|
||||
void encode_file_spu_interleaved(settings_t *settings, FILE *output);
|
||||
void encode_file_xa(settings_t *settings, FILE *output);
|
||||
void encode_file_str(settings_t *settings, FILE *output);
|
||||
void encode_file_sbs(settings_t *settings, FILE *output);
|
||||
|
||||
// mdec.c
|
||||
void encode_block_str(uint8_t *video_frames, int video_frame_count, uint8_t *output, settings_t *settings);
|
||||
void encode_frame_bs(uint8_t *video_frame, settings_t *settings);
|
||||
void encode_sector_str(uint8_t *video_frames, uint8_t *output, settings_t *settings);
|
||||
|
||||
Reference in New Issue
Block a user