Control: tags -1 + patch pending Dear maintainer,
I've prepared an NMU for libphash (versioned as 0.9.4-1.3) and uploaded it to DELAYED/2. Please feel free to tell me if I should delay it longer. Regards. -- Sebastian Ramacher
diff -u libphash-0.9.4/src/cimgffmpeg.cpp libphash-0.9.4/src/cimgffmpeg.cpp
--- libphash-0.9.4/src/cimgffmpeg.cpp
+++ libphash-0.9.4/src/cimgffmpeg.cpp
@@ -29,7 +29,7 @@
if (vfinfo->pFormatCtx != NULL){
avcodec_close(vfinfo->pCodecCtx);
vfinfo->pCodecCtx = NULL;
- av_close_input_file(vfinfo->pFormatCtx);
+ avformat_close_input(&vfinfo->pFormatCtx);
vfinfo->pFormatCtx = NULL;
vfinfo->width = -1;
vfinfo->height = -1;
@@ -54,11 +54,11 @@
av_register_all();
// Open video file
- if(av_open_input_file(&st_info->pFormatCtx, st_info->filename, NULL, 0, NULL)!=0)
+ if(avformat_open_input(&st_info->pFormatCtx, st_info->filename, NULL, NULL)!=0)
return -1 ; // Couldn't open file
// Retrieve stream information
- if(av_find_stream_info(st_info->pFormatCtx)<0)
+ if(avformat_find_stream_info(st_info->pFormatCtx,NULL)<0)
return -1; // Couldn't find stream information
//dump_format(pFormatCtx,0,NULL,0);//debugging function to print infomation about format
@@ -90,7 +90,7 @@
return -1 ; // Codec not found
}
// Open codec
- if(avcodec_open(st_info->pCodecCtx, st_info->pCodec)<0)
+ if(avcodec_open2(st_info->pCodecCtx, st_info->pCodec,NULL)<0)
return -1; // Could not open codec
st_info->height = (st_info->height<=0) ? st_info->pCodecCtx->height : st_info->height;
@@ -122,11 +122,10 @@
int frameFinished;
int size = 0;
- AVPacket packet;
- AVPacket avpacket;
- av_init_packet(&avpacket);
+ int channels = ffmpeg_pixfmt == PIX_FMT_GRAY8 ? 1 : 3;
+ AVPacket packet;
int result = 1;
CImg<uint8_t> next_image;
SwsContext *c = sws_getContext(st_info->pCodecCtx->width, st_info->pCodecCtx->height, st_info->pCodecCtx->pix_fmt, st_info->width, st_info->height, ffmpeg_pixfmt , SWS_BICUBIC, NULL, NULL, NULL);
@@ -135,27 +134,29 @@
if (result < 0)
break;
if(packet.stream_index==st_info->videoStream) {
- avpacket.data = packet.data;
- avpacket.size = packet.size;
- avpacket.flags = AV_PKT_FLAG_KEY;
- avcodec_decode_video2(st_info->pCodecCtx, pFrame, &frameFinished, &avpacket);
+
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
+ avpkt.data = packet.data;
+ avpkt.size = packet.size;
+ //
+ // HACK for CorePNG to decode as normal PNG by default
+ // same method used by ffmpeg
+ avpkt.flags = AV_PKT_FLAG_KEY;
+
+ avcodec_decode_video2(st_info->pCodecCtx, pFrame, &frameFinished,&avpkt);
+
+ // avcodec_decode_video(st_info->pCodecCtx, pFrame, &frameFinished,packet.data, packet.size);
+
if(frameFinished) {
if (st_info->current_index == st_info->next_index){
st_info->next_index += st_info->step;
sws_scale(c, pFrame->data, pFrame->linesize, 0, st_info->pCodecCtx->height, pConvertedFrame->data, pConvertedFrame->linesize);
- if (ffmpeg_pixfmt == PIX_FMT_GRAY8) {
- next_image.assign(pConvertedFrame->data[0],1,st_info->width,st_info->height,1,true);
- next_image.permute_axes("yzcx");
- pFrameList->push_back(next_image);
- size++;
- }
- else if (ffmpeg_pixfmt == PIX_FMT_RGB24){
- next_image.assign(*pConvertedFrame->data,3,st_info->width,st_info->height,1,true);
- next_image.permute_axes("yzcx");
- pFrameList->push_back(next_image);
- size++;
- }
+ next_image.assign(*pConvertedFrame->data, channels,st_info->width,st_info->height,1,true);
+ next_image.permute_axes("yzcx");
+ pFrameList->push_back(next_image);
+ size++;
}
st_info->current_index++;
}
@@ -166,7 +167,7 @@
if (result < 0){
avcodec_close(st_info->pCodecCtx);
- av_close_input_file(st_info->pFormatCtx);
+ avformat_close_input(&st_info->pFormatCtx);
st_info->pFormatCtx = NULL;
st_info->pCodecCtx = NULL;
st_info->width = -1;
@@ -206,12 +207,12 @@
av_log_set_level(AV_LOG_QUIET);
// Open video file
- if(av_open_input_file(&(st_info->pFormatCtx),st_info->filename,NULL,0,NULL)!=0){
+ if(avformat_open_input(&st_info->pFormatCtx,st_info->filename,NULL,NULL)!=0){
return -1 ; // Couldn't open file
}
// Retrieve stream information
- if(av_find_stream_info(st_info->pFormatCtx)<0){
+ if(avformat_find_stream_info(st_info->pFormatCtx,NULL)<0){
return -1; // Couldn't find stream information
}
@@ -241,7 +242,7 @@
return -1 ; // Codec not found
}
// Open codec
- if(avcodec_open(st_info->pCodecCtx, st_info->pCodec)<0){
+ if(avcodec_open2(st_info->pCodecCtx, st_info->pCodec,NULL)<0){
return -1; // Could not open codec
}
@@ -275,10 +276,6 @@
int frameFinished;
int size = 0;
AVPacket packet;
-
- AVPacket avpacket;
- av_init_packet(&avpacket);
-
int result = 1;
CImg<uint8_t> next_image;
SwsContext *c = sws_getContext(st_info->pCodecCtx->width, st_info->pCodecCtx->height, st_info->pCodecCtx->pix_fmt, st_info->width, st_info->height, ffmpeg_pixfmt , SWS_BICUBIC, NULL, NULL, NULL);
@@ -290,10 +287,20 @@
break;
if(packet.stream_index == st_info->videoStream) {
- avpacket.data = packet.data;
- avpacket.size = packet.size;
- avpacket.flags = AV_PKT_FLAG_KEY;
- avcodec_decode_video2(st_info->pCodecCtx, pFrame, &frameFinished, &avpacket);
+ int channels = ffmpeg_pixfmt == PIX_FMT_GRAY8 ? 1 : 3;
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
+ avpkt.data = packet.data;
+ avpkt.size = packet.size;
+ //
+ // HACK for CorePNG to decode as normal PNG by default
+ // same method used by ffmpeg
+ avpkt.flags = AV_PKT_FLAG_KEY;
+
+ avcodec_decode_video2(st_info->pCodecCtx, pFrame, &frameFinished,&avpkt);
+
+ // avcodec_decode_video(st_info->pCodecCtx, pFrame, &frameFinished,
+ // packet.data,packet.size);
if(frameFinished) {
if (st_info->current_index == st_info->next_index)
@@ -302,18 +309,10 @@
sws_scale(c, pFrame->data, pFrame->linesize, 0, st_info->pCodecCtx->height, pConvertedFrame->data, pConvertedFrame->linesize);
- if (ffmpeg_pixfmt == PIX_FMT_RGB24){
- next_image.assign(*pConvertedFrame->data,3,st_info->width,st_info->height,1,true);
- next_image.permute_axes("yzcx");
- pFrameList->push_back(next_image);
- size++;
- }
- else if (ffmpeg_pixfmt == PIX_FMT_GRAY8){
- next_image.assign(pConvertedFrame->data[0],1,st_info->width,st_info->height,1,true);
+ next_image.assign(*pConvertedFrame->data, channels, st_info->width,st_info->height,1,true);
next_image.permute_axes("yzcx");
pFrameList->push_back(next_image);
size++;
- }
}
st_info->current_index++;
@@ -333,7 +332,7 @@
if (result < 0)
{
avcodec_close(st_info->pCodecCtx);
- av_close_input_file(st_info->pFormatCtx);
+ avformat_close_input(&st_info->pFormatCtx);
st_info->pCodecCtx = NULL;
st_info->pFormatCtx = NULL;
st_info->pCodec = NULL;
@@ -349,14 +348,14 @@
av_log_set_level(AV_LOG_QUIET);
av_register_all();
// Open video file
- if (av_open_input_file(&pFormatCtx, file, NULL, 0, NULL))
+ if (avformat_open_input(&pFormatCtx, file, NULL, NULL))
return -1 ; // Couldn't open file
// Retrieve stream information
- if(av_find_stream_info(pFormatCtx)<0)
+ if(avformat_find_stream_info(pFormatCtx, NULL)<0)
return -1; // Couldn't find stream information
int result = pFormatCtx->nb_streams;
- av_close_input_file(pFormatCtx);
+ avformat_close_input(&pFormatCtx);
return result;
}
@@ -367,11 +366,11 @@
av_log_set_level(AV_LOG_QUIET);
av_register_all();
// Open video file
- if (av_open_input_file(&pFormatCtx, file, NULL, 0, NULL))
+ if (avformat_open_input(&pFormatCtx, file, NULL, NULL))
return -1 ; // Couldn't open file
// Retrieve stream information
- if(av_find_stream_info(pFormatCtx)<0)
+ if(avformat_find_stream_info(pFormatCtx, NULL)<0)
return -1; // Couldn't find stream information
// Find the first video stream
@@ -391,14 +390,17 @@
nb_frames = str->nb_frames;
if (nb_frames > 0)
{ //the easy way if value is already contained in struct
- av_close_input_file(pFormatCtx);
+ avformat_close_input(&pFormatCtx);
return nb_frames;
}
else { // frames must be counted
AVPacket packet;
nb_frames = (long)av_index_search_timestamp(str,str->duration, AVSEEK_FLAG_ANY|AVSEEK_FLAG_BACKWARD);
// Close the video file
- av_close_input_file(pFormatCtx);
+ int timebase = str->time_base.den / str->time_base.num;
+ if (nb_frames <= 0)
+ nb_frames = str->duration/timebase;
+ avformat_close_input(&pFormatCtx);
return nb_frames;
}
}
@@ -409,11 +411,11 @@
AVFormatContext *pFormatCtx;
// Open video file
- if (av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL))
+ if (avformat_open_input(&pFormatCtx, filename, NULL, NULL))
return -1 ; // Couldn't open file
// Retrieve stream information
- if(av_find_stream_info(pFormatCtx)<0)
+ if(avformat_find_stream_info(pFormatCtx,NULL)<0)
return -1; // Couldn't find stream information
// Find the first video stream
@@ -433,7 +435,7 @@
int den = (pFormatCtx->streams[videoStream]->r_frame_rate).den;
result = num/den;
- av_close_input_file(pFormatCtx);
+ avformat_close_input(&pFormatCtx);
return result;
diff -u libphash-0.9.4/debian/changelog libphash-0.9.4/debian/changelog
--- libphash-0.9.4/debian/changelog
+++ libphash-0.9.4/debian/changelog
@@ -1,3 +1,11 @@
+libphash (0.9.4-1.3) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * Apply libav 9 compatibility fixes from 0.9.6 to fix the build failure with
+ libav 9. (Closes: #720797)
+
+ -- Sebastian Ramacher <[email protected]> Mon, 02 Sep 2013 21:13:44 +0200
+
libphash (0.9.4-1.2) unstable; urgency=low
* Non-maintainer upload.
signature.asc
Description: Digital signature

