Skip to content

Commit

Permalink
add AV_ to ffmpeg const and remove deinterlacing
Browse files Browse the repository at this point in the history
  • Loading branch information
ckxng committed Mar 4, 2019
1 parent 0fb31d6 commit f675346
Showing 1 changed file with 11 additions and 27 deletions.
38 changes: 11 additions & 27 deletions ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename)
#endif
/* Manually override the codec id. */
if (of)
of->video_codec = CODEC_ID_MSMPEG4V2;
of->video_codec = AV_CODEC_ID_MSMPEG4V2;

} else if (strcmp(codec, "swf") == 0) {
ext = ".swf";
Expand All @@ -390,7 +390,7 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename)
#else
of = av_guess_format("flv", NULL, NULL);
#endif
of->video_codec = CODEC_ID_FLV1;
of->video_codec = AV_CODEC_ID_FLV1;
} else if (strcmp(codec, "ffv1") == 0) {
ext = ".avi";
#ifdef GUESS_NO_DEPRECATED
Expand All @@ -403,7 +403,7 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename)
* Requires strict_std_compliance to be <= -2
*/
if (of)
of->video_codec = CODEC_ID_FFV1;
of->video_codec = AV_CODEC_ID_FFV1;

} else if (strcmp(codec, "mov") == 0) {
ext = ".mov";
Expand Down Expand Up @@ -499,7 +499,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename,

/* Create a new video stream and initialize the codecs. */
ffmpeg->video_st = NULL;
if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) {
if (ffmpeg->oc->oformat->video_codec != AV_CODEC_ID_NONE) {
#if defined FF_API_NEW_AVIO
ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */);
#else
Expand All @@ -526,7 +526,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename,
#else
c->codec_type = AVMEDIA_TYPE_VIDEO;
#endif
is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO;
is_mpeg1 = c->codec_id == AV_CODEC_ID_MPEG1VIDEO;

if (strcmp(ffmpeg_video_codec, "ffv1") == 0)
c->strict_std_compliance = -2;
Expand Down Expand Up @@ -595,7 +595,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename,
}

/* Set the picture format - need in ffmpeg starting round April-May 2005 */
c->pix_fmt = PIX_FMT_YUV420P;
c->pix_fmt = AV_PIX_FMT_YUV420P;

/* Get a mutex lock. */
pthread_mutex_lock(&global_lock);
Expand Down Expand Up @@ -632,10 +632,10 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename,
}

/* Allocate the encoded raw picture. */
ffmpeg->picture = avcodec_alloc_frame();
ffmpeg->picture = av_frame_alloc();

if (!ffmpeg->picture) {
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_alloc_frame -"
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: av_frame_alloc -"
" could not alloc frame");
ffmpeg_cleanups(ffmpeg);
return NULL;
Expand Down Expand Up @@ -949,7 +949,7 @@ AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y,
{
AVFrame *picture;

picture = avcodec_alloc_frame();
picture = av_frame_alloc();

if (!picture) {
MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Could not alloc frame");
Expand All @@ -974,7 +974,7 @@ AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y,

/**
* ffmpeg_deinterlace
* Make the image suitable for deinterlacing using ffmpeg, then deinterlace the picture.
* avpicture_deinterlace is no longer supported in recent versions of ffmpeg
*
* Parameters
* img image in YUV420P format
Expand All @@ -983,26 +983,10 @@ AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y,
*
* Returns
* Function returns nothing.
* img contains deinterlaced image
* img is unchanged
*/
void ffmpeg_deinterlace(unsigned char *img, int width, int height)
{
AVPicture picture;
int width2 = width / 2;

picture.data[0] = img;
picture.data[1] = img + width * height;
picture.data[2] = picture.data[1] + (width * height) / 4;
picture.linesize[0] = width;
picture.linesize[1] = width2;
picture.linesize[2] = width2;

/* We assume using 'PIX_FMT_YUV420P' always */
avpicture_deinterlace(&picture, &picture, PIX_FMT_YUV420P, width, height);

#ifndef __SSE_MATH__
__asm__ __volatile__ ( "emms");
#endif

return;
}
Expand Down

1 comment on commit f675346

@ckxng
Copy link
Owner Author

@ckxng ckxng commented on f675346 Mar 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relates to sackmotion#17, discovered after pushing

Please sign in to comment.